diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/DynamicTableTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/DynamicTableTest.java index a23bd4a879a2..66d556ecb8cd 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/DynamicTableTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/DynamicTableTest.java @@ -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); @@ -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); @@ -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) { diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java index cb68bad9f33d..f805c7d6eda4 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java @@ -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) @@ -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); @@ -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())