public class CompressorHttp2ConnectionEncoder extends DecoratingHttp2ConnectionEncoder
content-encoding header for each
 stream. The compression provided by this class will be applied to the data for the entire stream.Http2FrameWriter.Configuration| Modifier and Type | Field and Description | 
|---|---|
static int | 
DEFAULT_COMPRESSION_LEVEL  | 
static int | 
DEFAULT_MEM_LEVEL  | 
static int | 
DEFAULT_WINDOW_BITS  | 
| Constructor and Description | 
|---|
CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate)
Create a new  
CompressorHttp2ConnectionEncoder instance
 with default implementation of StandardCompressionOptions | 
CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate,
                                CompressionOptions... compressionOptionsArgs)
Create a new  
CompressorHttp2ConnectionEncoder with
 specified StandardCompressionOptions | 
CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate,
                                int compressionLevel,
                                int windowBits,
                                int memLevel)
Deprecated.  
 | 
| Modifier and Type | Method and Description | 
|---|---|
protected CharSequence | 
getTargetContentEncoding(CharSequence contentEncoding)
Returns the expected content encoding of the decoded content. 
 | 
protected EmbeddedChannel | 
newContentCompressor(ChannelHandlerContext ctx,
                    CharSequence contentEncoding)
Returns a new  
EmbeddedChannel that encodes the HTTP2 message content encoded in the specified
 contentEncoding. | 
ChannelFuture | 
writeData(ChannelHandlerContext ctx,
         int streamId,
         ByteBuf data,
         int padding,
         boolean endOfStream,
         ChannelPromise promise)
Writes a  
DATA frame to the remote endpoint. | 
ChannelFuture | 
writeHeaders(ChannelHandlerContext ctx,
            int streamId,
            Http2Headers headers,
            int padding,
            boolean endStream,
            ChannelPromise promise)
Writes a HEADERS frame to the remote endpoint. 
 | 
ChannelFuture | 
writeHeaders(ChannelHandlerContext ctx,
            int streamId,
            Http2Headers headers,
            int streamDependency,
            short weight,
            boolean exclusive,
            int padding,
            boolean endOfStream,
            ChannelPromise promise)
Writes a HEADERS frame with priority specified to the remote endpoint. 
 | 
connection, consumeReceivedSettings, flowController, frameWriter, lifecycleManager, pollSentSettings, remoteSettingsclose, configuration, writeFrame, writeGoAway, writePing, writePriority, writePushPromise, writeRstStream, writeSettings, writeSettingsAck, writeWindowUpdateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwriteFrameclose, configuration, writeGoAway, writePing, writePriority, writePushPromise, writeRstStream, writeSettings, writeSettingsAck, writeWindowUpdatepublic static final int DEFAULT_COMPRESSION_LEVEL
public static final int DEFAULT_WINDOW_BITS
public static final int DEFAULT_MEM_LEVEL
public CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate)
CompressorHttp2ConnectionEncoder instance
 with default implementation of StandardCompressionOptions@Deprecated public CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate, int compressionLevel, int windowBits, int memLevel)
CompressorHttp2ConnectionEncoder instancepublic CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate, CompressionOptions... compressionOptionsArgs)
CompressorHttp2ConnectionEncoder with
 specified StandardCompressionOptionspublic ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream, ChannelPromise promise)
Http2DataWriterDATA frame to the remote endpoint. This will result in one or more
 frames being written to the context.writeData in interface Http2DataWriterwriteData in class DecoratingHttp2FrameWriterctx - the context to use for writing.streamId - the stream for which to send the frame.data - the payload of the frame. This will be released by this method.padding - additional bytes that should be added to obscure the true content size. Must be between 0 and
                256 (inclusive). A 1 byte padding is encoded as just the pad length field with value 0.
                A 256 byte padding is encoded as the pad length field with value 255 and 255 padding bytes
                appended to the end of the frame.endOfStream - indicates if this is the last frame to be sent for the stream.promise - the promise for the write.public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, ChannelPromise promise)
Http2FrameWriterwriteHeaders in interface Http2FrameWriterwriteHeaders in class DecoratingHttp2FrameWriterctx - the context to use for writing.streamId - the stream for which to send the frame.headers - the headers to be sent.padding - additional bytes that should be added to obscure the true content size. Must be between 0 and
                256 (inclusive).endStream - indicates if this is the last frame to be sent for the stream.promise - the promise for the write.The header block MUST be processed to ensure a consistent connection state, unless the connection is closed.If this call has modified the HPACK header state you MUST throw a connection error.
If this call has NOT modified the HPACK header state you are free to throw a stream error.
public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream, ChannelPromise promise)
Http2FrameWriterwriteHeaders in interface Http2FrameWriterwriteHeaders in class DecoratingHttp2FrameWriterctx - the context to use for writing.streamId - the stream for which to send the frame.headers - the headers to be sent.streamDependency - the stream on which this stream should depend, or 0 if it should
            depend on the connection.weight - the weight for this stream.exclusive - whether this stream should be the exclusive dependant of its parent.padding - additional bytes that should be added to obscure the true content size. Must be between 0 and
                256 (inclusive).endOfStream - indicates if this is the last frame to be sent for the stream.promise - the promise for the write.The header block MUST be processed to ensure a consistent connection state, unless the connection is closed.If this call has modified the HPACK header state you MUST throw a connection error.
If this call has NOT modified the HPACK header state you are free to throw a stream error.
protected EmbeddedChannel newContentCompressor(ChannelHandlerContext ctx, CharSequence contentEncoding) throws Http2Exception
EmbeddedChannel that encodes the HTTP2 message content encoded in the specified
 contentEncoding.ctx - the context.contentEncoding - the value of the content-encoding headerByteToMessageDecoder if the specified encoding is supported. null otherwise
 (alternatively, you can throw a Http2Exception to block unknown encoding).Http2Exception - If the specified encoding is not supported and warrants an exceptionprotected CharSequence getTargetContentEncoding(CharSequence contentEncoding) throws Http2Exception
contentEncoding is the default
 behavior, which is the case for most compressors.contentEncoding - the value of the content-encoding headerHttp2Exception - if the contentEncoding is not supported and warrants an exceptionCopyright © 2008–2025 The Netty Project. All rights reserved.