Top Description Fields Constructors Methods
io.netty5.handler.codec.http

public Class HttpContentCompressor

extends HttpContentEncoder
Class Inheritance
Imports
io.netty5.handler.codec.compression.Brotli, .BrotliCompressor, .BrotliOptions, .CompressionOptions, .Compressor, .DeflateOptions, .GzipOptions, .StandardCompressionOptions, .ZlibCompressor, .ZlibWrapper, .Zstd, .ZstdCompressor, .ZstdOptions, io.netty5.util.internal.ObjectUtil, java.util.HashMap, .Map, java.util.function.Supplier

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.

Field Summary

Modifier and TypeField and Description
private final BrotliOptions
private final int
private final int
private final DeflateOptions
private final Map<String, Supplier<? extends Compressor>>
private final GzipOptions
private final boolean
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.
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 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.netty5.handler.codec.http.HttpContentEncoder.beginEncode.

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

protected ZlibWrapper
determineWrapper(String acceptEncoding)

Deprecated
Inherited from io.netty5.handler.codec.http.HttpContentEncoder:
acceptOutboundMessagechannelInactivedecodedecodeAndCloseencodeAndClosehandlerRemoved

Field Detail

brotliOptionsback to summary
private final BrotliOptions brotliOptions
compressionLevelback to summary
private final int compressionLevel
contentSizeThresholdback to summary
private final int contentSizeThreshold
deflateOptionsback to summary
private final DeflateOptions deflateOptions
factoriesback to summary
private final Map<String, Supplier<? extends Compressor>> factories
gzipOptionsback to summary
private final GzipOptions gzipOptions
supportsCompressionOptionsback to summary
private final boolean supportsCompressionOptions
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.

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 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.

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)

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

Doc from io.netty5.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