Skip to content

Commit

Permalink
Fix #10805 zero dynamic table (#11445)
Browse files Browse the repository at this point in the history
* Added test for #10805 Zero Dynamic Table

* fixed file header

* Added test for #10805 Zero Dynamic Table

* Fix for #10805 Zero Dynamic Table

Set the correct default size for the table.
Always send the max table size on the first encode
  • Loading branch information
gregw committed Feb 26, 2024
1 parent bd0e76a commit 41e53fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
});

if (clientMaxCapacity >= 0)
client.setMaxEncoderTableCapacity(0);
client.setMaxEncoderTableCapacity(clientMaxCapacity);
if (serverMaxCapacity >= 0)
connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).setMaxEncoderTableCapacity(serverMaxCapacity);

Expand Down Expand Up @@ -103,7 +103,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
});

if (clientMaxCapacity >= 0)
client.setMaxDecoderTableCapacity(0);
client.setMaxDecoderTableCapacity(clientMaxCapacity);
if (serverMaxCapacity >= 0)
connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).setMaxDecoderTableCapacity(serverMaxCapacity);

Expand Down Expand Up @@ -151,8 +151,8 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO

if (clientMaxCapacity >= 0)
{
client.setMaxDecoderTableCapacity(0);
client.setMaxEncoderTableCapacity(0);
client.setMaxDecoderTableCapacity(clientMaxCapacity);
client.setMaxEncoderTableCapacity(clientMaxCapacity);
}
if (serverMaxCapacity >= 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public class HpackEncoder
private int _maxHeaderListSize;
private int _headerListSize;
private boolean _validateEncoding = true;
private boolean _maxDynamicTableSizeSent = false;

@Deprecated
public HpackEncoder(int localMaxDynamicTableSize)
Expand All @@ -128,7 +129,7 @@ public HpackEncoder(int localMaxDynamicTableSize, int remoteMaxDynamicTableSize,

public HpackEncoder()
{
_context = new HpackContext(0);
_context = new HpackContext(HpackContext.DEFAULT_MAX_TABLE_CAPACITY);
_debug = LOG.isDebugEnabled();
setMaxTableCapacity(HpackContext.DEFAULT_MAX_TABLE_CAPACITY);
setTableCapacity(HpackContext.DEFAULT_MAX_TABLE_CAPACITY);
Expand Down Expand Up @@ -235,8 +236,11 @@ public void encode(ByteBuffer buffer, MetaData metadata) throws HpackException

// If max table size changed, send the correspondent instruction.
int tableCapacity = getTableCapacity();
if (tableCapacity != _context.getMaxDynamicTableSize())
if (!_maxDynamicTableSizeSent || tableCapacity != _context.getMaxDynamicTableSize())
{
_maxDynamicTableSizeSent = true;
encodeMaxDynamicTableSize(buffer, tableCapacity);
}

// Add Request/response meta fields
if (metadata.isRequest())
Expand Down

0 comments on commit 41e53fa

Please sign in to comment.