GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Overview
  • Use
  • Tree
  • Deprecated
  • Index
  • Search
  • Help
  • io.netty.handler.codec.http
  • HttpContentCompressor

This view

  • Original page
  • New address

GeezerVison is showing netty.io — HttpContentCompressor (Netty API Reference (4.1.141.Final))

Class HttpContentCompressor

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.MessageToMessageCodec<HttpRequest, HttpObject>
io.netty.handler.codec.http.HttpContentEncoder
io.netty.handler.codec.http.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.
  • Nested Class Summary

    Nested classes/interfaces inherited from class HttpContentEncoder

    HttpContentEncoder.Result
    Modifier and Type
    Class
    Description
    static final class 
    HttpContentEncoder.Result
     

    Nested classes/interfaces inherited from interface ChannelHandler

    ChannelHandler.Sharable
    Modifier and Type
    Interface
    Description
    static @interface 
    ChannelHandler.Sharable
    Indicates that the same instance of the annotated ChannelHandler can be added to one or more ChannelPipelines multiple times without a race condition.
  • Field Summary

    Fields inherited from class HttpContentEncoder

    DEFAULT_MAX_PIPELINE_DEPTH
    Modifier and Type
    Field
    Description
    static final int
    DEFAULT_MAX_PIPELINE_DEPTH
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    HttpContentCompressor()
    Creates a new handler with StandardCompressionOptions.brotli() (if supported) , StandardCompressionOptions.zstd() (if supported), StandardCompressionOptions.snappy(), StandardCompressionOptions.gzip() and StandardCompressionOptions.deflate().
    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, int maxPipelineDepth, CompressionOptions... compressionOptions)
    Create a new HttpContentCompressor instance with specified CompressionOptionss
    HttpContentCompressor(int contentSizeThreshold, CompressionOptions... compressionOptions)
    Create a new HttpContentCompressor instance with specified CompressionOptionss
    HttpContentCompressor(CompressionOptions... compressionOptions)
    Create a new HttpContentCompressor Instance with specified CompressionOptionss and contentSizeThreshold set to 0
  • Method Summary

    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.
    void
    handlerAdded(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.

    Methods inherited from class HttpContentEncoder

    acceptOutboundMessage, channelInactive, decode, encode, handlerRemoved
    Modifier and Type
    Method
    Description
    boolean
    acceptOutboundMessage(Object msg)
    Returns true if and only if the specified message can be encoded by this codec.
    void
    channelInactive(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelInactive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    protected void
    decode(ChannelHandlerContext ctx, HttpRequest msg, List<Object> out)
     
    protected void
    encode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out)
     
    void
    handlerRemoved(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.

    Methods inherited from class MessageToMessageCodec

    acceptInboundMessage, channelRead, channelReadComplete, write
    Modifier and Type
    Method
    Description
    boolean
    acceptInboundMessage(Object msg)
    Returns true if and only if the specified message can be decoded by this codec.
    void
    channelRead(ChannelHandlerContext ctx, Object msg)
    Calls ChannelHandlerContext.fireChannelRead(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelReadComplete(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelReadComplete() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
    Calls ChannelOutboundInvoker.write(Object, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read
    Modifier and Type
    Method
    Description
    void
    bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
    Calls ChannelOutboundInvoker.bind(SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    close(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
    Calls ChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    deregister(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.deregister(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    disconnect(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.disconnect(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    flush(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.flush() to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    read(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.read() to forward to the next ChannelOutboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelInboundHandlerAdapter

    channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
    Modifier and Type
    Method
    Description
    void
    channelActive(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelActive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelRegistered(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelRegistered() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelUnregistered(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelUnregistered() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelWritabilityChanged(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelWritabilityChanged() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
    Calls ChannelHandlerContext.fireExceptionCaught(Throwable) to forward to the next ChannelHandler in the ChannelPipeline.
    void
    userEventTriggered(ChannelHandlerContext ctx, Object evt)
    Calls ChannelHandlerContext.fireUserEventTriggered(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelHandlerAdapter

    ensureNotSharable, isSharable
    Modifier and Type
    Method
    Description
    protected void
    ensureNotSharable()
    Throws IllegalStateException if ChannelHandlerAdapter.isSharable() returns true
    boolean
    isSharable()
    Return true if the implementation is ChannelHandler.Sharable and so can be added to different ChannelPipelines.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HttpContentCompressor

      public HttpContentCompressor()
      Creates a new handler with StandardCompressionOptions.brotli() (if supported) , StandardCompressionOptions.zstd() (if supported), StandardCompressionOptions.snappy(), StandardCompressionOptions.gzip() and StandardCompressionOptions.deflate().
    • 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.
    • HttpContentCompressor

      public HttpContentCompressor(int contentSizeThreshold, int maxPipelineDepth, 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.
      maxPipelineDepth - The maximum allowed depth of the encoding pipeline queue, the default value is set to HttpContentEncoder.DEFAULT_MAX_PIPELINE_DEPTH
      compressionOptions - CompressionOptions or null if the default should be used.
  • Method Details

    • handlerAdded

      public void handlerAdded(ChannelHandlerContext ctx) throws Exception
      Description copied from class: ChannelHandlerAdapter
      Do nothing by default, sub-classes may override this method.
      Specified by:
      handlerAdded in interface ChannelHandler
      Overrides:
      handlerAdded in class ChannelHandlerAdapter
      Throws:
      Exception
    • beginEncode

      protected HttpContentEncoder.Result beginEncode(HttpResponse httpResponse, String acceptEncoding) throws Exception
      Description copied from class: HttpContentEncoder
      Prepare to encode the HTTP message content.
      Specified by:
      beginEncode in class HttpContentEncoder
      Parameters:
      httpResponse - the http response
      acceptEncoding - 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 if acceptEncoding is unsupported or rejected and thus the content should be handled as-is (i.e. no encoding).
      Throws:
      Exception
    • determineEncoding

      protected String determineEncoding(String acceptEncoding)
    • determineWrapper

      @Deprecated protected ZlibWrapper determineWrapper(String acceptEncoding)
      Deprecated.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.