improved http2 static entry generation
This commit is contained in:
parent
6b489c78b6
commit
8c85b2f591
|
@ -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 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_SCHEME:
|
||||
{
|
||||
|
||||
HttpScheme scheme = HttpScheme.CACHE.get(value);
|
||||
if (scheme!=null)
|
||||
entry=new StaticEntry(i,new StaticTableHttpField(header,name,value,scheme));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
entry=new StaticEntry(i,new HttpField(STATIC_TABLE[i][0],STATIC_TABLE[i][1]));
|
||||
case C_STATUS:
|
||||
{
|
||||
entry=new StaticEntry(i,new StaticTableHttpField(header,name,value,Integer.valueOf(value)));
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue