Fixed default table size for the HpackDecoder.

This is necessary because the remote encoder may encode fields assuming that the default size is 4096, and never send the table resize instruction.
In this case, the decoder table cannot start at zero, it must start at the default of 4096.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2023-05-28 00:38:43 +02:00
parent 420ec7cc1d
commit 94c2649d7b
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
2 changed files with 1 additions and 5 deletions

View File

@ -50,7 +50,7 @@ public class HpackDecoder
*/ */
public HpackDecoder(int maxHeaderSize) public HpackDecoder(int maxHeaderSize)
{ {
_context = new HpackContext(0); _context = new HpackContext(HpackContext.DEFAULT_MAX_TABLE_CAPACITY);
_builder = new MetaDataBuilder(maxHeaderSize); _builder = new MetaDataBuilder(maxHeaderSize);
_huffmanDecoder = new HuffmanDecoder(); _huffmanDecoder = new HuffmanDecoder();
_integerDecoder = new NBitIntegerDecoder(); _integerDecoder = new NBitIntegerDecoder();

View File

@ -58,8 +58,6 @@ public class HpackDecoderTest
public void testDecodeD3() throws Exception public void testDecodeD3() throws Exception
{ {
HpackDecoder decoder = new HpackDecoder(8192); HpackDecoder decoder = new HpackDecoder(8192);
decoder.setMaxTableCapacity(HpackContext.DEFAULT_MAX_TABLE_CAPACITY);
decoder.getHpackContext().resize(decoder.getMaxTableCapacity());
// First request // First request
String encoded = "828684410f7777772e6578616d706c652e636f6d"; String encoded = "828684410f7777772e6578616d706c652e636f6d";
@ -108,8 +106,6 @@ public class HpackDecoderTest
public void testDecodeD4() throws Exception public void testDecodeD4() throws Exception
{ {
HpackDecoder decoder = new HpackDecoder(8192); HpackDecoder decoder = new HpackDecoder(8192);
decoder.setMaxTableCapacity(HpackContext.DEFAULT_MAX_TABLE_CAPACITY);
decoder.getHpackContext().resize(decoder.getMaxTableCapacity());
// First request // First request
String encoded = "828684418cf1e3c2e5f23a6ba0ab90f4ff"; String encoded = "828684418cf1e3c2e5f23a6ba0ab90f4ff";