@@ -110,7 +110,7 @@ public final class NettyChannelBuilder extends ForwardingChannelBuilder2<NettyCh
110110 private boolean autoFlowControl = DEFAULT_AUTO_FLOW_CONTROL ;
111111 private int flowControlWindow = DEFAULT_FLOW_CONTROL_WINDOW ;
112112 private final Set <AsciiString > neverIndexedMetadataKeys = new HashSet <>();
113- private boolean disableHpackDynamicTable ;
113+ private int hpackDynamicTableSize = GrpcHttp2HeadersEncoder . DEFAULT_DYNAMIC_TABLE_SIZE ;
114114 private int maxHeaderListSize = GrpcUtil .DEFAULT_MAX_HEADER_LIST_SIZE ;
115115 private int softLimitHeaderListSize = GrpcUtil .DEFAULT_MAX_HEADER_LIST_SIZE ;
116116 private int maxInboundMessageSize = GrpcUtil .DEFAULT_MAX_MESSAGE_SIZE ;
@@ -478,17 +478,17 @@ public NettyChannelBuilder neverIndexMetadataKeys(
478478 }
479479
480480 /**
481- * Disables use of the HPACK dynamic table for HTTP/2 header compression.
481+ * Sets the maximum HPACK dynamic table size, in bytes, for both directions of a connection.
482+ * The peer may advertise a smaller maximum for headers encoded by this endpoint. A value of
483+ * zero disables the dynamic table while retaining HPACK static-table references and Huffman
484+ * encoding. By default, HTTP/2's standard 4 KiB capacity is used.
482485 *
483- * <p>HPACK itself remains enabled, as required by HTTP/2. Static table references may still be
484- * used. Disabling the dynamic table reduces per-connection memory usage, but can increase the
485- * size of header blocks. The inbound dynamic table is disabled after the peer acknowledges the
486- * corresponding HTTP/2 setting, and requires a peer that correctly implements that setting. By
487- * default, the dynamic table is enabled.
486+ * @throws IllegalArgumentException if {@code bytes} is negative
488487 */
489488 @ CanIgnoreReturnValue
490- public NettyChannelBuilder disableHpackDynamicTable () {
491- disableHpackDynamicTable = true ;
489+ public NettyChannelBuilder hpackDynamicTableSize (int bytes ) {
490+ checkArgument (bytes >= 0 , "hpackDynamicTableSize must not be negative: %s" , bytes );
491+ hpackDynamicTableSize = bytes ;
492492 return this ;
493493 }
494494
@@ -685,7 +685,7 @@ ClientTransportFactory buildTransportFactory() {
685685 autoFlowControl ,
686686 flowControlWindow ,
687687 neverIndexedMetadataKeys ,
688- disableHpackDynamicTable ,
688+ hpackDynamicTableSize ,
689689 maxInboundMessageSize ,
690690 maxHeaderListSize ,
691691 softLimitHeaderListSize ,
@@ -830,7 +830,7 @@ private static final class NettyTransportFactory implements ClientTransportFacto
830830 private final boolean autoFlowControl ;
831831 private final int flowControlWindow ;
832832 private final Set <AsciiString > neverIndexedMetadataKeys ;
833- private final boolean disableHpackDynamicTable ;
833+ private final int hpackDynamicTableSize ;
834834 private final int maxMessageSize ;
835835 private final int maxHeaderListSize ;
836836 private final int softLimitHeaderListSize ;
@@ -853,7 +853,7 @@ private static final class NettyTransportFactory implements ClientTransportFacto
853853 boolean autoFlowControl ,
854854 int flowControlWindow ,
855855 Set <AsciiString > neverIndexedMetadataKeys ,
856- boolean disableHpackDynamicTable ,
856+ int hpackDynamicTableSize ,
857857 int maxMessageSize ,
858858 int maxHeaderListSize ,
859859 int softLimitHeaderListSize ,
@@ -873,7 +873,7 @@ private static final class NettyTransportFactory implements ClientTransportFacto
873873 this .flowControlWindow = flowControlWindow ;
874874 this .neverIndexedMetadataKeys = Collections .unmodifiableSet (
875875 new HashSet <>(checkNotNull (neverIndexedMetadataKeys , "neverIndexedMetadataKeys" )));
876- this .disableHpackDynamicTable = disableHpackDynamicTable ;
876+ this .hpackDynamicTableSize = hpackDynamicTableSize ;
877877 this .maxMessageSize = maxMessageSize ;
878878 this .maxHeaderListSize = maxHeaderListSize ;
879879 this .softLimitHeaderListSize = softLimitHeaderListSize ;
@@ -924,7 +924,7 @@ public void run() {
924924 autoFlowControl ,
925925 flowControlWindow ,
926926 neverIndexedMetadataKeys ,
927- disableHpackDynamicTable ,
927+ hpackDynamicTableSize ,
928928 maxMessageSize ,
929929 maxHeaderListSize ,
930930 softLimitHeaderListSize ,
@@ -965,7 +965,7 @@ public SwapChannelCredentialsResult swapChannelCredentials(ChannelCredentials ch
965965 autoFlowControl ,
966966 flowControlWindow ,
967967 neverIndexedMetadataKeys ,
968- disableHpackDynamicTable ,
968+ hpackDynamicTableSize ,
969969 maxMessageSize ,
970970 maxHeaderListSize ,
971971 softLimitHeaderListSize ,
0 commit comments