Class HttpContentCompressor

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler

public class HttpContentCompressor extends HttpContentEncoder
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 Details

    • supportsCompressionOptions

      private final boolean supportsCompressionOptions
    • gzipOptions

      private final GzipOptions gzipOptions
    • deflateOptions

      private final DeflateOptions deflateOptions
    • compressionLevel

      private final int compressionLevel
    • windowBits

      private final int windowBits
    • memLevel

      private final int memLevel
    • contentSizeThreshold

      private final int contentSizeThreshold
    • ctx

      private ChannelHandlerContext ctx
    • factories

      private final Map<String,CompressionEncoderFactory> factories
  • Constructor Details

    • 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 and 9 yields the best compression. 0 means no compression. The default compression level is 6.
    • 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 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
    • 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 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
      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 new HttpContentCompressor Instance with specified CompressionOptionss and contentSizeThreshold set to 0
      Parameters:
      compressionOptions - CompressionOptions or null if the default should be used.
    • HttpContentCompressor

      public HttpContentCompressor(int contentSizeThreshold, CompressionOptions... compressionOptions)
      Create a new HttpContentCompressor instance with specified CompressionOptionss
      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 or null if the default should be used.
  • Method Details