public void decode(ByteBuf headerBlock, final HttpHeaderBlockFrame frame) throws IOException { HeaderListener headerListener = NULL_HEADER_LISTENER; if (frame != null) { headerListener = new HeaderListenerImpl(frame.headers()); } if (cumulation == null) { decoder.decode(new ByteBufInputStream(headerBlock), headerListener); if (headerBlock.isReadable()) { cumulation = Unpooled.buffer(headerBlock.readableBytes()); cumulation.writeBytes(headerBlock); } } else { cumulation.writeBytes(headerBlock); decoder.decode(new ByteBufInputStream(cumulation), headerListener); if (cumulation.isReadable()) { cumulation.discardReadBytes(); } else { cumulation.release(); cumulation = null; } } }
@Benchmark @BenchmarkMode(Mode.Throughput) public void decode(final Blackhole bh) throws IOException { Decoder decoder = new Decoder(maxHeaderSize, maxTableSize); decoder.decode(new ByteArrayInputStream(input), new HeaderListener() { @Override public void addHeader(byte[] name, byte[] value, boolean sensitive) { bh.consume(sensitive); } }); decoder.endHeaderBlock(); }