add status 200 and method GET to ref set
This commit is contained in:
parent
347324b71b
commit
70223cbda9
|
@ -109,14 +109,14 @@ public class HpackContext
|
|||
|
||||
private static final Map<HttpField,Entry> __staticFieldMap = new HashMap<>();
|
||||
private static final Trie<Entry> __staticNameMap = new ArrayTernaryTrie<>(true,512);
|
||||
|
||||
private static final Entry[] __staticTable=new Entry[STATIC_TABLE.length];
|
||||
|
||||
private static final StaticEntry[] __staticTable=new StaticEntry[STATIC_TABLE.length];
|
||||
static
|
||||
{
|
||||
Set<String> added = new HashSet<>();
|
||||
for (int i=1;i<STATIC_TABLE.length;i++)
|
||||
{
|
||||
Entry entry;
|
||||
StaticEntry entry;
|
||||
switch(i)
|
||||
{
|
||||
case 2:
|
||||
|
@ -159,6 +159,10 @@ public class HpackContext
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final StaticEntry METHOD_GET=__staticTable[2];
|
||||
public static final StaticEntry STATUS_200=__staticTable[8];
|
||||
|
||||
|
||||
private int _maxHeaderTableSizeInBytes;
|
||||
private int _headerTableSizeInBytes;
|
||||
|
|
|
@ -172,32 +172,46 @@ public class HpackEncoder
|
|||
{
|
||||
// TODO Strategy decision to make!
|
||||
// Should we add to reference set or just always send as indexed?
|
||||
// Let's always send as indexed to reduce churn in header table!
|
||||
// BUGGER! Can't do that. Oh well all the static fields have small values, so
|
||||
// lets send as literal header, indexed name.
|
||||
// We don't need never indexed because the cookie fields are name only and we can
|
||||
// huffman encode the value for the same reason.
|
||||
|
||||
// Add the token
|
||||
buffer.put((byte)0x00);
|
||||
// Add the name index
|
||||
NBitInteger.encode(buffer,4,_context.index(entry));
|
||||
// Add the value
|
||||
buffer.put(entry.getStaticHuffmanValue());
|
||||
if (entry==HpackContext.METHOD_GET || entry==HpackContext.STATUS_200)
|
||||
{
|
||||
// :status: 200 and :method: GET are worthwhile putting into ref set.
|
||||
// as they are likely to be repeated.
|
||||
int index=_context.index(entry);
|
||||
buffer.put((byte)0x80);
|
||||
NBitInteger.encode(buffer,7,index);
|
||||
entry=_context.add(entry.getHttpField());
|
||||
if (entry!=null)
|
||||
_context.addToRefSet(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let's send other statics as indexed to reduce churn in header table!
|
||||
// BUGGER! Can't do that as we have to copy them into header table.
|
||||
// Oh well all the static fields have small values, so
|
||||
// lets send as literal header, indexed name.
|
||||
// We don't need never indexed because the cookie fields are name only and we can
|
||||
// huffman encode the value for the same reason.
|
||||
|
||||
// Add the token
|
||||
buffer.put((byte)0x00);
|
||||
// Add the name index
|
||||
NBitInteger.encode(buffer,4,_context.index(entry));
|
||||
// Add the value
|
||||
buffer.put(entry.getStaticHuffmanValue());
|
||||
|
||||
encoding="LiteralStaticIdxNameHuffmanValue";
|
||||
encoding="LiteralStaticIdxNameHuffmanValue";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
encoding="IdxField";
|
||||
|
||||
// So we can add the entry to the reference Set and emit the index;
|
||||
_context.addToRefSet(entry);
|
||||
// So we can emit the index and add the entry to the reference Set
|
||||
int index=_context.index(entry);
|
||||
|
||||
// TODO pregenerate indexes?
|
||||
buffer.put((byte)0x80);
|
||||
NBitInteger.encode(buffer,7,index);
|
||||
_context.addToRefSet(entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -118,7 +118,6 @@ public class Http2Server
|
|||
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
response.setHeader("custom","value");
|
||||
response.sendRedirect("http://www.google.com");
|
||||
response.setContentType("text/plain");
|
||||
String content = "Hello from Jetty HTTP2\n";
|
||||
response.setContentLength(content.length());
|
||||
|
|
Loading…
Reference in New Issue