5858import io .netty .buffer .ByteBuf ;
5959import io .netty .handler .codec .http2 .DefaultHttp2HeadersDecoder ;
6060import io .netty .handler .codec .http2 .Http2Exception ;
61- import io .netty .handler .codec .http2 .Http2HeaderTable ;
6261import io .netty .handler .codec .http2 .Http2Headers ;
6362import io .netty .handler .codec .http2 .Http2HeadersDecoder ;
6463import io .netty .handler .codec .http2 .internal .hpack .Decoder ;
@@ -79,21 +78,11 @@ abstract class GrpcHttp2HeadersDecoder implements Http2HeadersDecoder,
7978 private static final float HEADERS_COUNT_WEIGHT_NEW = 1 / 5f ;
8079 private static final float HEADERS_COUNT_WEIGHT_HISTORICAL = 1 - HEADERS_COUNT_WEIGHT_NEW ;
8180
82- private final Decoder decoder = new Decoder ();
83- private final Http2HeaderTable headerTable = new GrpcHttp2HeaderTable ();
81+ private final Decoder decoder ;
8482 private float numHeadersGuess = 8 ;
8583
8684 GrpcHttp2HeadersDecoder (long maxHeaderListSize ) {
87- try {
88- decoder .setMaxHeaderListSize (maxHeaderListSize );
89- } catch (Http2Exception e ) {
90- PlatformDependent .throwException (e );
91- }
92- }
93-
94- @ Override
95- public Http2HeaderTable headerTable () {
96- return headerTable ;
85+ decoder = new Decoder (maxHeaderListSize , 32 /* same as default */ );
9786 }
9887
9988 @ Override
@@ -114,26 +103,30 @@ public Configuration configuration() {
114103 return this ;
115104 }
116105
117- private final class GrpcHttp2HeaderTable implements Http2HeaderTable {
118- @ Override
119- public void maxHeaderTableSize (long max ) throws Http2Exception {
120- decoder .setMaxHeaderTableSize (max );
121- }
106+ @ Override
107+ public long maxHeaderListSize () {
108+ return decoder .getMaxHeaderListSize ();
109+ }
122110
123- @ Override
124- public long maxHeaderTableSize () {
125- return decoder .getMaxHeaderTableSize ();
126- }
111+ @ Override
112+ public void maxHeaderListSize (long maxHeaderListSize , long maxHeaderListSizeGoAway )
113+ throws Http2Exception {
114+ decoder .setMaxHeaderListSize (maxHeaderListSize , maxHeaderListSizeGoAway );
115+ }
127116
128- @ Override
129- public void maxHeaderListSize ( long max ) throws Http2Exception {
130- decoder .setMaxHeaderListSize ( max );
131- }
117+ @ Override
118+ public long maxHeaderListSizeGoAway () {
119+ return decoder .getMaxHeaderListSizeGoAway ( );
120+ }
132121
133- @ Override
134- public long maxHeaderListSize () {
135- return decoder .getMaxHeaderListSize ();
136- }
122+ @ Override
123+ public long maxHeaderTableSize () {
124+ return decoder .getMaxHeaderTableSize ();
125+ }
126+
127+ @ Override
128+ public void maxHeaderTableSize (long max ) throws Http2Exception {
129+ decoder .setMaxHeaderTableSize (max );
137130 }
138131
139132 static final class GrpcHttp2ServerHeadersDecoder extends GrpcHttp2HeadersDecoder {
0 commit comments