Top Description Inners Fields Constructors Methods
io.netty.handler.codec.http

public Class HttpContentCompressor

extends HttpContentEncoder
Class Inheritance
Imports
java.util.HashMap, .Map, io.netty.buffer.ByteBuf, io.netty.channel.ChannelHandlerContext, io.netty.channel.embedded.EmbeddedChannel, io.netty.handler.codec.MessageToByteEncoder, io.netty.handler.codec.compression.Brotli, .BrotliEncoder, .BrotliOptions, .CompressionOptions, .DeflateOptions, .GzipOptions, .StandardCompressionOptions, .ZlibCodecFactory, .ZlibEncoder, .ZlibWrapper, .Zstd, .ZstdEncoder, .ZstdOptions, .SnappyFrameEncoder, .SnappyOptions, io.netty.util.internal.ObjectUtil

Compresses an HttpMessage and an HttpContent in gzip or deflate encoding while respecting the "Accept-Encoding" header. If there is no matching encoding, no compression is done. For more information on how this handler modifies the message, please refer to HttpContentEncoder.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
HttpContentCompressor.BrEncoderFactory

Compression Encoder Factory that creates BrotliEncoders used to compress http content for br content encoding

private class
HttpContentCompressor.DeflateEncoderFactory

Compression Encoder Factory that creates ZlibEncoders used to compress http content for deflate content encoding

private class
HttpContentCompressor.GzipEncoderFactory

Compression Encoder Factory that creates ZlibEncoders used to compress http content for gzip content encoding

private static class
HttpContentCompressor.SnappyEncoderFactory

Compression Encoder Factory for create SnappyFrameEncoder used to compress http content for snappy content encoding

private class
HttpContentCompressor.ZstdEncoderFactory

Compression Encoder Factory for create ZstdEncoder used to compress http content for zstd content encoding

Field Summary

Modifier and TypeField and Description
private final BrotliOptions
private final int
private final int
private ChannelHandlerContext
private final DeflateOptions
private final Map<String, CompressionEncoderFactory>
private final GzipOptions
private final int
private final SnappyOptions
private final boolean
private final int
private final ZstdOptions

Constructor Summary

AccessConstructor and Description
public
HttpContentCompressor()

Creates a new handler with the default compression level (6), default window size (15) and default memory level (8).

public
HttpContentCompressor(int
1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level is 6.
compressionLevel
)

Deprecated
Creates a new handler with the specified compression level, default window size (15) and default memory level (8).
public
HttpContentCompressor(int
1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level is 6.
compressionLevel
,
int
The base two logarithm of the size of the history buffer. The value should be in the range 9 to 15 inclusive. Larger values result in better compression at the expense of memory usage. The default value is 15.
windowBits
,
int
How much memory should be allocated for the internal compression state. 1 uses minimum memory and 9 uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is 8
memLevel
)

Deprecated
Creates a new handler with the specified compression level, window size, and memory level..
public
HttpContentCompressor(int
1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level is 6.
compressionLevel
,
int
The base two logarithm of the size of the history buffer. The value should be in the range 9 to 15 inclusive. Larger values result in better compression at the expense of memory usage. The default value is 15.
windowBits
,
int
How much memory should be allocated for the internal compression state. 1 uses minimum memory and 9 uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is 8
memLevel
,
int
The response body is compressed when the size of the response body exceeds the threshold. The value should be a non negative number. 0 will enable compression for all responses.
contentSizeThreshold
)

Deprecated
Creates a new handler with the specified compression level, window size, and memory level..
public
HttpContentCompressor(CompressionOptions...
CompressionOptions or null if the default should be used.
compressionOptions
)

Create a new HttpContentCompressor Instance with specified CompressionOptionss and contentSizeThreshold set to 0

public
HttpContentCompressor(int
The response body is compressed when the size of the response body exceeds the threshold. The value should be a non negative number. 0 will enable compression for all responses.
contentSizeThreshold
,
CompressionOptions...
CompressionOptions or null if the default should be used.
compressionOptions
)

Create a new HttpContentCompressor instance with specified CompressionOptionss

Method Summary

Modifier and TypeMethod and Description
protected HttpContentEncoder.Result
beginEncode(HttpResponse
the http response
httpResponse
,
String
the value of the "Accept-Encoding" header
acceptEncoding
)

Implements abstract io.netty.handler.codec.http.HttpContentEncoder.beginEncode.

Prepare to encode the HTTP message content.
protected String
determineEncoding(String acceptEncoding)

protected ZlibWrapper
determineWrapper(String acceptEncoding)

Deprecated
public void
handlerAdded(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
Inherited from io.netty.handler.codec.http.HttpContentEncoder:
acceptOutboundMessagechannelInactivedecodeencodehandlerRemoved

Field Detail

brotliOptionsback to summary
private final BrotliOptions brotliOptions
compressionLevelback to summary
private final int compressionLevel
contentSizeThresholdback to summary
private final int contentSizeThreshold
ctxback to summary
private ChannelHandlerContext ctx
deflateOptionsback to summary
private final DeflateOptions deflateOptions
factoriesback to summary
private final Map<String, CompressionEncoderFactory> factories
gzipOptionsback to summary
private final GzipOptions gzipOptions
memLevelback to summary
private final int memLevel
snappyOptionsback to summary
private final SnappyOptions snappyOptions
supportsCompressionOptionsback to summary
private final boolean supportsCompressionOptions
windowBitsback to summary
private final int windowBits
zstdOptionsback to summary
private final ZstdOptions zstdOptions

Constructor Detail

HttpContentCompressorback to summary
public HttpContentCompressor()

Creates a new handler with the default compression level (6), default window size (15) and default memory level (8).

HttpContentCompressorback to summary
public HttpContentCompressor(int compressionLevel)

Deprecated

Creates a new handler with the specified compression level, default window size (15) and default memory level (8).

Parameters
compressionLevel:int

1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level is 6.

Annotations
@Deprecated
HttpContentCompressorback to summary
public HttpContentCompressor(int compressionLevel, int windowBits, int memLevel)

Deprecated

Creates a new handler with the specified compression level, window size, and memory level..

Parameters
compressionLevel:int

1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level is 6.

windowBits:int

The base two logarithm of the size of the history buffer. The value should be in the range 9 to 15 inclusive. Larger values result in better compression at the expense of memory usage. The default value is 15.

memLevel:int

How much memory should be allocated for the internal compression state. 1 uses minimum memory and 9 uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is 8

Annotations
@Deprecated
HttpContentCompressorback to summary
public HttpContentCompressor(int compressionLevel, int windowBits, int memLevel, int contentSizeThreshold)

Deprecated

Creates a new handler with the specified compression level, window size, and memory level..

Parameters
compressionLevel:int

1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level is 6.

windowBits:int

The base two logarithm of the size of the history buffer. The value should be in the range 9 to 15 inclusive. Larger values result in better compression at the expense of memory usage. The default value is 15.

memLevel:int

How much memory should be allocated for the internal compression state. 1 uses minimum memory and 9 uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is 8

contentSizeThreshold:int

The response body is compressed when the size of the response body exceeds the threshold. The value should be a non negative number. 0 will enable compression for all responses.

Annotations
@Deprecated
HttpContentCompressorback to summary
public HttpContentCompressor(CompressionOptions... compressionOptions)

Create a new HttpContentCompressor Instance with specified CompressionOptionss and contentSizeThreshold set to 0

Parameters
compressionOptions:CompressionOptions[]

CompressionOptions or null if the default should be used.

HttpContentCompressorback to summary
public HttpContentCompressor(int contentSizeThreshold, CompressionOptions... compressionOptions)

Create a new HttpContentCompressor instance with specified CompressionOptionss

Parameters
contentSizeThreshold:int

The response body is compressed when the size of the response body exceeds the threshold. The value should be a non negative number. 0 will enable compression for all responses.

compressionOptions:CompressionOptions[]

CompressionOptions or null if the default should be used.

Method Detail

beginEncodeback to summary
protected HttpContentEncoder.Result beginEncode(HttpResponse httpResponse, String acceptEncoding) throws Exception

Implements abstract io.netty.handler.codec.http.HttpContentEncoder.beginEncode.

Doc from io.netty.handler.codec.http.HttpContentEncoder.beginEncode.

Prepare to encode the HTTP message content.

Parameters
httpResponse:HttpResponse

the http response

acceptEncoding:String

the value of the "Accept-Encoding" header

Returns:HttpContentEncoder.Result

the result of preparation, which is composed of the determined target content encoding and a new EmbeddedChannel that encodes the content into the target content encoding. null if acceptEncoding is unsupported or rejected and thus the content should be handled as-is (i.e. no encoding).

Annotations
@Override
determineEncodingback to summary
protected String determineEncoding(String acceptEncoding)
Annotations
@SuppressWarnings:FloatingPointEquality
determineWrapperback to summary
protected ZlibWrapper determineWrapper(String acceptEncoding)

Deprecated

Annotations
@Deprecated
@SuppressWarnings:FloatingPointEquality
handlerAddedback to summary
public void handlerAdded(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Doc from io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Annotations
@Override
io.netty.handler.codec.http back to summary

private final Class HttpContentCompressor.BrEncoderFactory

extends Object
implements CompressionEncoderFactory
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http.HttpContentCompressor.BrEncoderFactory
All Implemented Interfaces
io.netty.handler.codec.http.CompressionEncoderFactory

Compression Encoder Factory that creates BrotliEncoders used to compress http content for br content encoding

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MessageToByteEncoder<ByteBuf>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

BrEncoderFactoryback to summary
private BrEncoderFactory()

Method Detail

createEncoderback to summary
public MessageToByteEncoder<ByteBuf> createEncoder()

Implements io.netty.handler.codec.http.CompressionEncoderFactory.createEncoder.

Annotations
@Override
io.netty.handler.codec.http back to summary

private final Class HttpContentCompressor.DeflateEncoderFactory

extends Object
implements CompressionEncoderFactory
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http.HttpContentCompressor.DeflateEncoderFactory
All Implemented Interfaces
io.netty.handler.codec.http.CompressionEncoderFactory

Compression Encoder Factory that creates ZlibEncoders used to compress http content for deflate content encoding

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MessageToByteEncoder<ByteBuf>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DeflateEncoderFactoryback to summary
private DeflateEncoderFactory()

Method Detail

createEncoderback to summary
public MessageToByteEncoder<ByteBuf> createEncoder()

Implements io.netty.handler.codec.http.CompressionEncoderFactory.createEncoder.

Annotations
@Override
io.netty.handler.codec.http back to summary

private final Class HttpContentCompressor.GzipEncoderFactory

extends Object
implements CompressionEncoderFactory
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http.HttpContentCompressor.GzipEncoderFactory
All Implemented Interfaces
io.netty.handler.codec.http.CompressionEncoderFactory

Compression Encoder Factory that creates ZlibEncoders used to compress http content for gzip content encoding

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MessageToByteEncoder<ByteBuf>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

GzipEncoderFactoryback to summary
private GzipEncoderFactory()

Method Detail

createEncoderback to summary
public MessageToByteEncoder<ByteBuf> createEncoder()

Implements io.netty.handler.codec.http.CompressionEncoderFactory.createEncoder.

Annotations
@Override
io.netty.handler.codec.http back to summary

private final Class HttpContentCompressor.SnappyEncoderFactory

extends Object
implements CompressionEncoderFactory
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http.HttpContentCompressor.SnappyEncoderFactory
All Implemented Interfaces
io.netty.handler.codec.http.CompressionEncoderFactory

Compression Encoder Factory for create SnappyFrameEncoder used to compress http content for snappy content encoding

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MessageToByteEncoder<ByteBuf>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SnappyEncoderFactoryback to summary
private SnappyEncoderFactory()

Method Detail

createEncoderback to summary
public MessageToByteEncoder<ByteBuf> createEncoder()

Implements io.netty.handler.codec.http.CompressionEncoderFactory.createEncoder.

Annotations
@Override
io.netty.handler.codec.http back to summary

private final Class HttpContentCompressor.ZstdEncoderFactory

extends Object
implements CompressionEncoderFactory
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http.HttpContentCompressor.ZstdEncoderFactory
All Implemented Interfaces
io.netty.handler.codec.http.CompressionEncoderFactory

Compression Encoder Factory for create ZstdEncoder used to compress http content for zstd content encoding

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MessageToByteEncoder<ByteBuf>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ZstdEncoderFactoryback to summary
private ZstdEncoderFactory()

Method Detail

createEncoderback to summary
public MessageToByteEncoder<ByteBuf> createEncoder()

Implements io.netty.handler.codec.http.CompressionEncoderFactory.createEncoder.

Annotations
@Override