Class HttpContentCompressor
java.lang.Object
org.jboss.netty.channel.SimpleChannelHandler
org.jboss.netty.handler.codec.http.HttpContentEncoder
org.jboss.netty.handler.codec.http.HttpContentCompressor
- All Implemented Interfaces:
ChannelDownstreamHandler
,ChannelHandler
,ChannelUpstreamHandler
,LifeCycleAwareChannelHandler
Compresses an
HttpMessage
and an HttpChunk
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 Class Summary
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private static final int
private static final int
private static final InternalLogger
private final int
private static final boolean
private final int
-
Constructor Summary
ConstructorsConstructorDescriptionHttpContentCompressor
(int compressionLevel) HttpContentCompressor
(int compressionLevel, int windowBits, int memLevel) Creates a new handler with the specified compression level, window size, and memory level. -
Method Summary
Modifier and TypeMethodDescriptionprivate static ZlibWrapper
determineWrapper
(String acceptEncoding) protected String
getTargetContentEncoding
(String acceptEncoding) Returns the expected content encoding of the encoded content.protected EncoderEmbedder<ChannelBuffer>
newContentEncoder
(HttpMessage msg, String acceptEncoding) Returns a newEncoderEmbedder
that encodes the HTTP message content.Methods inherited from class org.jboss.netty.handler.codec.http.HttpContentEncoder
afterAdd, afterRemove, beforeAdd, beforeRemove, channelClosed, messageReceived, writeRequested
Methods inherited from class org.jboss.netty.channel.SimpleChannelHandler
bindRequested, channelBound, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, exceptionCaught, handleDownstream, handleUpstream, setInterestOpsRequested, unbindRequested, writeComplete
-
Field Details
-
logger
-
DEFAULT_JDK_WINDOW_SIZE
private static final int DEFAULT_JDK_WINDOW_SIZE- See Also:
-
DEFAULT_JDK_MEM_LEVEL
private static final int DEFAULT_JDK_MEM_LEVEL- See Also:
-
noJdkZlibEncoder
private static final boolean noJdkZlibEncoder -
compressionLevel
private final int compressionLevel -
windowBits
private final int windowBits -
memLevel
private final int memLevel
-
-
Constructor Details
-
HttpContentCompressor
public HttpContentCompressor() -
HttpContentCompressor
public HttpContentCompressor(int compressionLevel) 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
public HttpContentCompressor(int compressionLevel, int windowBits, int memLevel) 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 is 15.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 is 8.
-
-
Method Details
-
newContentEncoder
protected EncoderEmbedder<ChannelBuffer> newContentEncoder(HttpMessage msg, String acceptEncoding) throws Exception Description copied from class:HttpContentEncoder
Returns a newEncoderEmbedder
that encodes the HTTP message content.- Specified by:
newContentEncoder
in classHttpContentEncoder
acceptEncoding
- the value of the"Accept-Encoding"
header- Returns:
- a new
EncoderEmbedder
if there is a supported encoding inacceptEncoding
.null
otherwise. - Throws:
Exception
-
getTargetContentEncoding
Description copied from class:HttpContentEncoder
Returns the expected content encoding of the encoded content.- Specified by:
getTargetContentEncoding
in classHttpContentEncoder
- Parameters:
acceptEncoding
- the value of the"Accept-Encoding"
header- Returns:
- the expected content encoding of the new content
- Throws:
Exception
-
determineWrapper
-