Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.netty.handler.codec.http
Class HttpContentDecoder

    java.lang.Object
      org.jboss.netty.channel.SimpleChannelUpstreamHandler
          org.jboss.netty.handler.codec.http.HttpContentDecoder

All Implemented Interfaces:
  ChannelHandler, ChannelUpstreamHandler

Direct Known Subclasses:
  HttpContentDecompressor

    public abstract class HttpContentDecoder

extends SimpleChannelUpstreamHandler

Decodes the content of the received `HttpRequest` and `HttpChunk`. The original content is replaced with the new content decoded by the `DecoderEmbedder`, which is created by `newContentDecoder(String)`. Once decoding is finished, the value of the `'Content-Encoding'` header is set to the target content encoding, as returned by `getTargetContentEncoding(String)`. Also, the `'Content-Length'` header is updated to the length of the decoded content. If the content encoding of the original is not supported by the decoder, `newContentDecoder(String)` should return `null` so that no decoding occurs (i.e. pass-through).

Please note that this is an abstract class. You have to extend this class and implement `newContentDecoder(String)` properly to make this class functional. For example, refer to the source code of `HttpContentDecompressor`.

This handler must be placed after `HttpMessageDecoder` in the pipeline so that this handler can intercept HTTP requests after `HttpMessageDecoder` converts `ChannelBuffer`s into HTTP requests.

Version:
  $Rev: 2368 $, $Date: 2010-10-18 17:19:03 +0900 (Mon, 18 Oct 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
`protected` | `HttpContentDecoder()` Creates a new instance.

Method Summary
`protected String` | `getTargetContentEncoding(String contentEncoding)` Returns the expected content encoding of the decoded content.
`void` | `messageReceived(ChannelHandlerContext ctx, MessageEvent e)` Invoked when a message object (e.g: `ChannelBuffer`) was received from a remote peer.
`protected abstract DecoderEmbedder<ChannelBuffer>` | `newContentDecoder(String contentEncoding)` Returns a new `DecoderEmbedder` that decodes the HTTP message content encoded in the specified `contentEncoding`.

Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
`channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, exceptionCaught, handleUpstream, writeComplete`

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

Constructor Detail

### HttpContentDecoder

    protected HttpContentDecoder()

  Creates a new instance.

Method Detail

### messageReceived

    public void messageReceived(ChannelHandlerContext ctx,
                                MessageEvent e)
                         throws Exception

  Description copied from class: `SimpleChannelUpstreamHandler`
  Invoked when a message object (e.g: `ChannelBuffer`) was received from a remote peer.

  Overrides:
    `messageReceived` in class `SimpleChannelUpstreamHandler`
  Throws:
    `Exception`

### newContentDecoder

    protected abstract DecoderEmbedder<ChannelBuffer> newContentDecoder(String contentEncoding)
                                                                 throws Exception

  Returns a new `DecoderEmbedder` that decodes the HTTP message content encoded in the specified `contentEncoding`.

  Parameters:
    `contentEncoding` - the value of the `"Content-Encoding"` header
  Returns:
    a new `DecoderEmbedder` if the specified encoding is supported. `null` otherwise (alternatively, you can throw an exception to block unknown encoding).
  Throws:
    `Exception`

### getTargetContentEncoding

    protected String getTargetContentEncoding(String contentEncoding)
                                       throws Exception

  Returns the expected content encoding of the decoded content. This method returns `"identity"` by default, which is the case for most decoders.

  Parameters:
    `contentEncoding` - the value of the `"Content-Encoding"` header
  Returns:
    the expected content encoding of the new content
  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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