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
public class HttpContentCompressor extends HttpContentEncoder
Compresses anHttpMessageand anHttpChunkingzipordeflateencoding 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 interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private intcompressionLevelprivate static intDEFAULT_JDK_MEM_LEVELprivate static intDEFAULT_JDK_WINDOW_SIZEprivate static InternalLoggerloggerprivate intmemLevelprivate static booleannoJdkZlibEncoderprivate intwindowBits
-
Constructor Summary
Constructors Constructor Description HttpContentCompressor()HttpContentCompressor(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static ZlibWrapperdetermineWrapper(java.lang.String acceptEncoding)protected java.lang.StringgetTargetContentEncoding(java.lang.String acceptEncoding)Returns the expected content encoding of the encoded content.protected EncoderEmbedder<ChannelBuffer>newContentEncoder(HttpMessage msg, java.lang.String acceptEncoding)Returns a newEncoderEmbedderthat 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 Detail
-
logger
private static final InternalLogger logger
-
DEFAULT_JDK_WINDOW_SIZE
private static final int DEFAULT_JDK_WINDOW_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_JDK_MEM_LEVEL
private static final int DEFAULT_JDK_MEM_LEVEL
- See Also:
- Constant Field Values
-
noJdkZlibEncoder
private static final boolean noJdkZlibEncoder
-
compressionLevel
private final int compressionLevel
-
windowBits
private final int windowBits
-
memLevel
private final int memLevel
-
-
Constructor Detail
-
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-1yields the fastest compression and9yields the best compression.0means 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-1yields the fastest compression and9yields the best compression.0means 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 range9to15inclusive. 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.1uses minimum memory and9uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is 8.
-
-
Method Detail
-
newContentEncoder
protected EncoderEmbedder<ChannelBuffer> newContentEncoder(HttpMessage msg, java.lang.String acceptEncoding) throws java.lang.Exception
Description copied from class:HttpContentEncoderReturns a newEncoderEmbedderthat encodes the HTTP message content.- Specified by:
newContentEncoderin classHttpContentEncoderacceptEncoding- the value of the"Accept-Encoding"header- Returns:
- a new
EncoderEmbedderif there is a supported encoding inacceptEncoding.nullotherwise. - Throws:
java.lang.Exception
-
getTargetContentEncoding
protected java.lang.String getTargetContentEncoding(java.lang.String acceptEncoding) throws java.lang.ExceptionDescription copied from class:HttpContentEncoderReturns the expected content encoding of the encoded content.- Specified by:
getTargetContentEncodingin classHttpContentEncoder- Parameters:
acceptEncoding- the value of the"Accept-Encoding"header- Returns:
- the expected content encoding of the new content
- Throws:
java.lang.Exception
-
determineWrapper
private static ZlibWrapper determineWrapper(java.lang.String acceptEncoding)
-
-