1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.spdy.server.http;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 import org.eclipse.jetty.spdy.api.SPDY;
25
26
27
28
29
30
31 public enum HTTPSPDYHeader
32 {
33 METHOD("method", ":method"),
34 URI("url", ":path"),
35 VERSION("version", ":version"),
36 SCHEME("scheme", ":scheme"),
37 HOST("host", ":host"),
38 STATUS("status", ":status");
39
40 public static HTTPSPDYHeader from(short version, String name)
41 {
42 switch (version)
43 {
44 case SPDY.V2:
45 return Names.v2Names.get(name);
46 case SPDY.V3:
47 return Names.v3Names.get(name);
48 default:
49 throw new IllegalStateException();
50 }
51 }
52
53 private final String v2Name;
54 private final String v3Name;
55
56 private HTTPSPDYHeader(String v2Name, String v3Name)
57 {
58 this.v2Name = v2Name;
59 Names.v2Names.put(v2Name, this);
60 this.v3Name = v3Name;
61 Names.v3Names.put(v3Name, this);
62 }
63
64 public String name(short version)
65 {
66 switch (version)
67 {
68 case SPDY.V2:
69 return v2Name;
70 case SPDY.V3:
71 return v3Name;
72 default:
73 throw new IllegalStateException();
74 }
75 }
76
77 private static class Names
78 {
79 private static final Map<String, HTTPSPDYHeader> v2Names = new HashMap<>();
80 private static final Map<String, HTTPSPDYHeader> v3Names = new HashMap<>();
81 }
82 }