## org.jboss.netty.handler.codec.http
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

    public class HttpContentCompressor

extends HttpContentEncoder

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`.

Version:
  $Rev: 2121 $, $Date: 2010-02-02 09:38:07 +0900 (Tue, 02 Feb 2010) $
Author:
  The Netty Project, Trustin Lee

Nested Class Summary

Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
`ChannelHandler.Sharable`

Constructor Summary
`HttpContentCompressor()` Creates a new handler with the default compression level (`6`).
`HttpContentCompressor(int compressionLevel)` Creates a new handler with the specified compression level.

Method Summary
`protected String` `getTargetContentEncoding(String acceptEncoding)` Returns the expected content encoding of the encoded content.
`protected EncoderEmbedder<ChannelBuffer>` `newContentEncoder(String acceptEncoding)` Returns a new `EncoderEmbedder` that encodes the HTTP message content.

Methods inherited from class org.jboss.netty.handler.codec.http.HttpContentEncoder
`messageReceived, writeRequested`

Methods inherited from class org.jboss.netty.channel.SimpleChannelHandler
`bindRequested, channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, exceptionCaught, handleDownstream, handleUpstream, setInterestOpsRequested, unbindRequested, writeComplete`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### HttpContentCompressor

    public HttpContentCompressor()

  Creates a new handler with the default compression level (`6`).

### HttpContentCompressor

    public HttpContentCompressor(int compressionLevel)

  Creates a new handler with the specified compression level.

  Parameters:
    `compressionLevel` - `1` yields the fastest compression and `9` yields the best compression. `0` means no compression. The default compression level is `6`.

Method Detail

### newContentEncoder

    protected EncoderEmbedder<ChannelBuffer> newContentEncoder(String acceptEncoding)
                                                        throws Exception

  Description copied from class: `HttpContentEncoder`
  Returns a new `EncoderEmbedder` that encodes the HTTP message content.

  Specified by:
    `newContentEncoder` in class `HttpContentEncoder`
  Parameters:
    `acceptEncoding` - the value of the `"Accept-Encoding"` header
  Returns:
    a new `EncoderEmbedder` if there is a supported encoding in `acceptEncoding`. `null` otherwise.
  Throws:
    `Exception`

### getTargetContentEncoding

    protected String getTargetContentEncoding(String acceptEncoding)
                                       throws Exception

  Description copied from class: `HttpContentEncoder`
  Returns the expected content encoding of the encoded content.

  Specified by:
    `getTargetContentEncoding` in class `HttpContentEncoder`
  Parameters:
    `acceptEncoding` - the value of the `"Accept-Encoding"` header
  Returns:
    the expected content encoding of the new content
  Throws:
    `Exception`

Copyright © 2008-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.