@Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        Object out = msg;

        if (msg instanceof HttpResponse && (hasDeflateTransferEncoding(((HttpResponse) msg).headers()))) {
            ctx.attr(INFLATER).set(new Inflater());
        }

        if (msg instanceof HttpContent) {
            final Inflater decompressor = ctx.attr(INFLATER).get();
            if (null == decompressor) {
                super.channelRead(ctx, msg);
                return;
            }

            final ByteBuf chunk = ((HttpContent) msg).content();
            decompressor.setInput(ByteBufUtil.getBytes(chunk));
            final int decompressedSizeEstimate = chunk.readableBytes() * 8;
            byte[] outBuf = new byte[Math.max(decompressedSizeEstimate, MIN_BUFFER_SIZE)];

            try {
                int writeIdx = 0;
                int bytesWritten = decompressor.inflate(outBuf, writeIdx, outBuf.length);

                while (bytesWritten == (outBuf.length - writeIdx)) {
                    writeIdx += bytesWritten;
                    outBuf = Arrays.copyOf(outBuf, outBuf.length * 2);
                    bytesWritten = decompressor.inflate(outBuf, writeIdx, outBuf.length - writeIdx);
                }

                writeIdx += bytesWritten;
                out = ((HttpContent) msg).replace(Unpooled.wrappedBuffer(outBuf).writerIndex(writeIdx));
                ReferenceCountUtil.release(msg);

                if (out instanceof LastHttpContent) { ctx.attr(INFLATER).getAndSet(null).end(); }
            } catch (DataFormatException dfe) {
                ctx.attr(INFLATER).getAndSet(null).end();
                ctx.fireExceptionCaught(dfe);
                return;
            }
        }

        super.channelRead(ctx, out);
    }
Handles decompression of content when the response contains the "Content-Encoding" header. Currently supports "deflate".
This class is specifically meant to work with serialized GraphBinary chunks as they need to be inflated per chunk such
that the chunk ends with a Marker.END_OF_STREAM.
gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/HttpContentDecompressionHandler.java