- java.lang.Object
-
- io.netty5.channel.ChannelHandlerAdapter
-
- io.netty5.handler.codec.MessageToMessageCodec<HttpRequest,HttpObject>
-
- io.netty5.handler.codec.http.HttpContentEncoder
-
- io.netty5.handler.codec.http.HttpContentCompressor
-
- All Implemented Interfaces:
ChannelHandler
public class HttpContentCompressor extends HttpContentEncoder
Compresses anHttpMessage
and anHttpContent
ingzip
ordeflate
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 toHttpContentEncoder
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.netty5.handler.codec.http.HttpContentEncoder
HttpContentEncoder.Result
-
-
Constructor Summary
Constructors Constructor Description HttpContentCompressor()
Creates a new handler with the default compression level (6), default window size (15) and default memory level (8).HttpContentCompressor(int compressionLevel)
Deprecated.HttpContentCompressor(int compressionLevel, int windowBits, int memLevel)
Deprecated.HttpContentCompressor(int compressionLevel, int windowBits, int memLevel, int contentSizeThreshold)
Deprecated.HttpContentCompressor(int contentSizeThreshold, CompressionOptions... compressionOptions)
Create a newHttpContentCompressor
instance with specifiedCompressionOptions
sHttpContentCompressor(CompressionOptions... compressionOptions)
Create a newHttpContentCompressor
Instance with specifiedCompressionOptions
s and contentSizeThreshold set to0
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected HttpContentEncoder.Result
beginEncode(HttpResponse httpResponse, String acceptEncoding)
Prepare to encode the HTTP message content.protected String
determineEncoding(String acceptEncoding)
protected ZlibWrapper
determineWrapper(String acceptEncoding)
Deprecated.-
Methods inherited from class io.netty5.handler.codec.http.HttpContentEncoder
acceptOutboundMessage, channelInactive, decode, decodeAndClose, encodeAndClose, handlerRemoved
-
Methods inherited from class io.netty5.handler.codec.MessageToMessageCodec
acceptInboundMessage, channelRead, encode, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelExceptionCaught, channelInboundEvent, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown
-
-
-
-
Constructor Detail
-
HttpContentCompressor
public HttpContentCompressor()
Creates a new handler with the default compression level (6), default window size (15) and default memory level (8).
-
HttpContentCompressor
@Deprecated 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
-1
yields the fastest compression and9
yields the best compression.0
means no compression. The default compression level is6
.
-
HttpContentCompressor
@Deprecated 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
-1
yields the fastest compression and9
yields the best compression.0
means no compression. The default compression level is6
.windowBits
- The base two logarithm of the size of the history buffer. The value should be in the range9
to15
inclusive. Larger values result in better compression at the expense of memory usage. The default value is15
.memLevel
- How much memory should be allocated for the internal compression state.1
uses minimum memory and9
uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is8
-
HttpContentCompressor
@Deprecated 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
-1
yields the fastest compression and9
yields the best compression.0
means no compression. The default compression level is6
.windowBits
- The base two logarithm of the size of the history buffer. The value should be in the range9
to15
inclusive. Larger values result in better compression at the expense of memory usage. The default value is15
.memLevel
- How much memory should be allocated for the internal compression state.1
uses minimum memory and9
uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is8
contentSizeThreshold
- 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.
-
HttpContentCompressor
public HttpContentCompressor(CompressionOptions... compressionOptions)
Create a newHttpContentCompressor
Instance with specifiedCompressionOptions
s and contentSizeThreshold set to0
- Parameters:
compressionOptions
-CompressionOptions
ornull
if the default should be used.
-
HttpContentCompressor
public HttpContentCompressor(int contentSizeThreshold, CompressionOptions... compressionOptions)
Create a newHttpContentCompressor
instance with specifiedCompressionOptions
s- Parameters:
contentSizeThreshold
- 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
ornull
if the default should be used.
-
-
Method Detail
-
beginEncode
protected HttpContentEncoder.Result beginEncode(HttpResponse httpResponse, String acceptEncoding)
Description copied from class:HttpContentEncoder
Prepare to encode the HTTP message content.- Specified by:
beginEncode
in classHttpContentEncoder
- Parameters:
httpResponse
- the http responseacceptEncoding
- the value of the"Accept-Encoding"
header- Returns:
- 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
ifacceptEncoding
is unsupported or rejected and thus the content should be handled as-is (i.e. no encoding).
-
determineWrapper
@Deprecated protected ZlibWrapper determineWrapper(String acceptEncoding)
Deprecated.
-
-