diff options
author | Greg Wilkins | 2014-10-15 03:04:54 +0000 |
---|---|---|
committer | Greg Wilkins | 2014-10-15 03:04:54 +0000 |
commit | 8c85b2f59170c7b0a74e4c2400827cce51e8d6fe (patch) | |
tree | bf188562455a057142da30c4604502af03193278 /jetty-http2/http2-hpack | |
parent | 6b489c78b64dbc8eb5717bdfa7a27c1dcc40e5d5 (diff) | |
download | org.eclipse.jetty.project-8c85b2f59170c7b0a74e4c2400827cce51e8d6fe.tar.gz org.eclipse.jetty.project-8c85b2f59170c7b0a74e4c2400827cce51e8d6fe.tar.xz org.eclipse.jetty.project-8c85b2f59170c7b0a74e4c2400827cce51e8d6fe.zip |
improved http2 static entry generation
Diffstat (limited to 'jetty-http2/http2-hpack')
2 files changed, 44 insertions, 29 deletions
diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java index d427212d91..8bc7c725f0 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java @@ -114,37 +114,47 @@ public class HpackContext Set<String> added = new HashSet<>(); for (int i=1;i<STATIC_TABLE.length;i++) { - StaticEntry entry; - switch(i) + StaticEntry entry=null; + + String name = STATIC_TABLE[i][0]; + String value = STATIC_TABLE[i][1]; + HttpHeader header = HttpHeader.CACHE.get(name); + if (header!=null && value!=null) { - case 2: - entry=new StaticEntry(i,new StaticTableHttpField(STATIC_TABLE[i][0],STATIC_TABLE[i][1],HttpMethod.GET)); - break; - case 3: - entry=new StaticEntry(i,new StaticTableHttpField(STATIC_TABLE[i][0],STATIC_TABLE[i][1],HttpMethod.POST)); - break; - case 6: - entry=new StaticEntry(i,new StaticTableHttpField(STATIC_TABLE[i][0],STATIC_TABLE[i][1],HttpScheme.HTTP)); - break; - case 7: - entry=new StaticEntry(i,new StaticTableHttpField(STATIC_TABLE[i][0],STATIC_TABLE[i][1],HttpScheme.HTTPS)); - break; - case 8: - case 11: - entry=new StaticEntry(i,new StaticTableHttpField(STATIC_TABLE[i][0],STATIC_TABLE[i][1],Integer.valueOf(STATIC_TABLE[i][1]))); - break; + switch (header) + { + case C_METHOD: + { + + HttpMethod method = HttpMethod.CACHE.get(value); + if (method!=null) + entry=new StaticEntry(i,new StaticTableHttpField(header,name,value,method)); + break; + } + + case C_SCHEME: + { + + HttpScheme scheme = HttpScheme.CACHE.get(value); + if (scheme!=null) + entry=new StaticEntry(i,new StaticTableHttpField(header,name,value,scheme)); + break; + } - case 9: - case 10: - case 12: - case 13: - case 14: - entry=new StaticEntry(i,new StaticTableHttpField(STATIC_TABLE[i][0],STATIC_TABLE[i][1],Integer.valueOf(STATIC_TABLE[i][1]))); - break; + case C_STATUS: + { + entry=new StaticEntry(i,new StaticTableHttpField(header,name,value,Integer.valueOf(value))); + break; + } - default: - entry=new StaticEntry(i,new HttpField(STATIC_TABLE[i][0],STATIC_TABLE[i][1])); + default: + break; + } } + + if (entry==null) + entry=new StaticEntry(i,header==null?new HttpField(STATIC_TABLE[i][0],value):new HttpField(header,name,value)); + __staticTable[i]=entry; diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/StaticTableHttpField.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/StaticTableHttpField.java index cd1da1c910..bf7ec1dd0e 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/StaticTableHttpField.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/StaticTableHttpField.java @@ -27,14 +27,19 @@ public class StaticTableHttpField extends HttpField { private final Object _value; - public StaticTableHttpField(HttpHeader header,String valueString, Object value) + public StaticTableHttpField(HttpHeader header, String name, String valueString, Object value) { - super(header,header.asString(),valueString); + super(header,name,valueString); if (value==null) throw new IllegalArgumentException(); _value=value; } + public StaticTableHttpField(HttpHeader header,String valueString, Object value) + { + this (header,header.asString(),valueString, value); + } + public StaticTableHttpField(String name, String valueString, Object value) { super(name,valueString); |