public class HttpContentCompressor extends HttpContentEncoder
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
.HttpContentEncoder.Result
ChannelHandler.Sharable
构造器和说明 |
---|
HttpContentCompressor()
Creates a new handler with the default compression level (6),
default window size (15) and default memory level (8).
|
HttpContentCompressor(int compressionLevel)
Creates a new handler with the specified compression level, default
window size (15) and default memory level (8).
|
HttpContentCompressor(int compressionLevel,
int windowBits,
int memLevel)
Creates a new handler with the specified compression level, window size,
and memory level..
|
限定符和类型 | 方法和说明 |
---|---|
protected HttpContentEncoder.Result |
beginEncode(HttpResponse headers,
java.lang.String acceptEncoding)
Prepare to encode the HTTP message content.
|
protected ZlibWrapper |
determineWrapper(java.lang.String acceptEncoding) |
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
acceptOutboundMessage, channelInactive, decode, encode, handlerRemoved
acceptInboundMessage, channelRead, write
bind, close, connect, deregister, disconnect, flush, read
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exceptionCaught
public HttpContentCompressor()
public HttpContentCompressor(int compressionLevel)
compressionLevel
- 1
yields the fastest compression and 9
yields the
best compression. 0
means no compression. The default
compression level is 6
.public HttpContentCompressor(int compressionLevel, int windowBits, int memLevel)
compressionLevel
- 1
yields the fastest compression and 9
yields the
best compression. 0
means no compression. The default
compression level is 6
.windowBits
- 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
- 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
public void handlerAdded(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelHandlerAdapter
handlerAdded
在接口中 ChannelHandler
handlerAdded
在类中 ChannelHandlerAdapter
java.lang.Exception
protected HttpContentEncoder.Result beginEncode(HttpResponse headers, java.lang.String acceptEncoding) throws java.lang.Exception
HttpContentEncoder
beginEncode
在类中 HttpContentEncoder
headers
- the headersacceptEncoding
- the value of the "Accept-Encoding"
headerEmbeddedChannel
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).java.lang.Exception
protected ZlibWrapper determineWrapper(java.lang.String acceptEncoding)