private EmbeddedChannel newCompressor(ChannelHandlerContext ctx, Http2Headers headers, boolean endOfStream)
            throws Http2Exception {
        if (endOfStream) {
            return null;
        }

        CharSequence encoding = headers.get(CONTENT_ENCODING);
        if (encoding == null) {
            encoding = IDENTITY;
        }
        final EmbeddedChannel compressor = newContentCompressor(ctx, encoding);
        if (compressor != null) {
            CharSequence targetContentEncoding = getTargetContentEncoding(encoding);
            if (IDENTITY.contentEqualsIgnoreCase(targetContentEncoding)) {
                headers.remove(CONTENT_ENCODING);
            } else {
                headers.set(CONTENT_ENCODING, targetContentEncoding);
            }

            // The content length will be for the decompressed data. Since we will compress the data
            // this content-length will not be correct. Instead of queuing messages or delaying sending
            // header frames...just remove the content-length header
            headers.remove(CONTENT_LENGTH);
        }

        return compressor;
    }
private EmbeddedChannel newCompressor ( ChannelHandlerContext ctx , Http2Headers headers , boolean endOfStream ) throws Http2Exception { if ( endOfStream ) { return null ; } CharSequence encoding = headers . get ( CONTENT_ENCODING ) ; if ( encoding == null ) { encoding = IDENTITY ; } final EmbeddedChannel compressor = newContentCompressor ( ctx , encoding ) ; if ( compressor != null ) { CharSequence targetContentEncoding = getTargetContentEncoding ( encoding ) ; if ( IDENTITY . contentEqualsIgnoreCase ( targetContentEncoding ) ) { headers . remove ( CONTENT_ENCODING ) ; } else { headers . set ( CONTENT_ENCODING , targetContentEncoding ) ; } headers . remove ( CONTENT_LENGTH ) ; } return compressor ; }
Checks if a new compressor object is needed for the stream identified by {@code streamId}. This method will
modify the {@code content-encoding} header contained in {@code headers}.

@param ctx the context.
@param headers Object representing headers which are to be written
@param endOfStream Indicates if the stream has ended
@return The channel used to compress data.
@throws Http2Exception if any problems occur during initialization.