@@ -110,6 +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 ;
113114 private int maxHeaderListSize = GrpcUtil .DEFAULT_MAX_HEADER_LIST_SIZE ;
114115 private int softLimitHeaderListSize = GrpcUtil .DEFAULT_MAX_HEADER_LIST_SIZE ;
115116 private int maxInboundMessageSize = GrpcUtil .DEFAULT_MAX_MESSAGE_SIZE ;
@@ -476,6 +477,21 @@ public NettyChannelBuilder neverIndexMetadataKeys(
476477 return this ;
477478 }
478479
480+ /**
481+ * Disables use of the HPACK dynamic table for HTTP/2 header compression.
482+ *
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.
488+ */
489+ @ CanIgnoreReturnValue
490+ public NettyChannelBuilder disableHpackDynamicTable () {
491+ disableHpackDynamicTable = true ;
492+ return this ;
493+ }
494+
479495 /**
480496 * Sets the maximum size of header list allowed to be received. This is cumulative size of the
481497 * headers with some overhead, as defined for
@@ -669,6 +685,7 @@ ClientTransportFactory buildTransportFactory() {
669685 autoFlowControl ,
670686 flowControlWindow ,
671687 neverIndexedMetadataKeys ,
688+ disableHpackDynamicTable ,
672689 maxInboundMessageSize ,
673690 maxHeaderListSize ,
674691 softLimitHeaderListSize ,
@@ -813,6 +830,7 @@ private static final class NettyTransportFactory implements ClientTransportFacto
813830 private final boolean autoFlowControl ;
814831 private final int flowControlWindow ;
815832 private final Set <AsciiString > neverIndexedMetadataKeys ;
833+ private final boolean disableHpackDynamicTable ;
816834 private final int maxMessageSize ;
817835 private final int maxHeaderListSize ;
818836 private final int softLimitHeaderListSize ;
@@ -835,6 +853,7 @@ private static final class NettyTransportFactory implements ClientTransportFacto
835853 boolean autoFlowControl ,
836854 int flowControlWindow ,
837855 Set <AsciiString > neverIndexedMetadataKeys ,
856+ boolean disableHpackDynamicTable ,
838857 int maxMessageSize ,
839858 int maxHeaderListSize ,
840859 int softLimitHeaderListSize ,
@@ -854,6 +873,7 @@ private static final class NettyTransportFactory implements ClientTransportFacto
854873 this .flowControlWindow = flowControlWindow ;
855874 this .neverIndexedMetadataKeys = Collections .unmodifiableSet (
856875 new HashSet <>(checkNotNull (neverIndexedMetadataKeys , "neverIndexedMetadataKeys" )));
876+ this .disableHpackDynamicTable = disableHpackDynamicTable ;
857877 this .maxMessageSize = maxMessageSize ;
858878 this .maxHeaderListSize = maxHeaderListSize ;
859879 this .softLimitHeaderListSize = softLimitHeaderListSize ;
@@ -904,6 +924,7 @@ public void run() {
904924 autoFlowControl ,
905925 flowControlWindow ,
906926 neverIndexedMetadataKeys ,
927+ disableHpackDynamicTable ,
907928 maxMessageSize ,
908929 maxHeaderListSize ,
909930 softLimitHeaderListSize ,
@@ -944,6 +965,7 @@ public SwapChannelCredentialsResult swapChannelCredentials(ChannelCredentials ch
944965 autoFlowControl ,
945966 flowControlWindow ,
946967 neverIndexedMetadataKeys ,
968+ disableHpackDynamicTable ,
947969 maxMessageSize ,
948970 maxHeaderListSize ,
949971 softLimitHeaderListSize ,
0 commit comments