DefaultHttp2HeadersDecoder implements Http2HeadersDecoder, Http2HeadersDecoder.Configuration { @Override public Http2Headers decodeHeaders(int streamId, ByteBuf headerBlock) throws Http2Exception { try { final Http2Headers headers = newHeaders(); hpackDecoder.decode(streamId, headerBlock, headers); headerArraySizeAccumulator = HEADERS_COUNT_WEIGHT_NEW * headers.size() + HEADERS_COUNT_WEIGHT_HISTORICAL * headerArraySizeAccumulator; return headers; } catch (Http2Exception e) { throw e; } catch (Throwable e) { throw connectionError(COMPRESSION_ERROR, e, e.getMessage()); } } DefaultHttp2HeadersDecoder();  DefaultHttp2HeadersDecoder(boolean validateHeaders);  DefaultHttp2HeadersDecoder(boolean validateHeaders, long maxHeaderListSize);  DefaultHttp2HeadersDecoder(boolean validateHeaders, long maxHeaderListSize,
                                      int initialHuffmanDecodeCapacity);   DefaultHttp2HeadersDecoder(boolean validateHeaders, HpackDecoder hpackDecoder); @Override void maxHeaderTableSize(long max); @Override long maxHeaderTableSize(); @Override void maxHeaderListSize(long max, long goAwayMax); @Override long maxHeaderListSize(); @Override long maxHeaderListSizeGoAway(); @Override Configuration configuration(); @Override Http2Headers decodeHeaders(int streamId, ByteBuf headerBlock);  }
@Test public void decodeShouldSucceed() throws Exception { ByteBuf buf = encode(b(":method"), b("GET"), b("akey"), b("avalue"), randomBytes(), randomBytes()); try { Http2Headers headers = decoder.decodeHeaders(0, buf); assertEquals(3, headers.size()); assertEquals("GET", headers.method().toString()); assertEquals("avalue", headers.get(new AsciiString("akey")).toString()); } finally { buf.release(); } }
@Test public void decodeLargerThanHeaderListSizeButLessThanGoAwayWithInitialDecoderSettings() throws Exception { ByteBuf buf = encode(b(":method"), b("GET"), b("test_header"), b(String.format("%09000d", 0).replace('0', 'A'))); final int streamId = 1; try { decoder.decodeHeaders(streamId, buf); fail(); } catch (Http2Exception.HeaderListSizeException e) { assertEquals(streamId, e.streamId()); } finally { buf.release(); } }