org.jboss.netty.handler.codec.http

## Class HttpChunkAggregator

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

- All Implemented Interfaces:
    ChannelHandler, ChannelUpstreamHandler, LifeCycleAwareChannelHandler

      public class HttpChunkAggregator
      extends SimpleChannelUpstreamHandler
      implements LifeCycleAwareChannelHandler

  A `ChannelHandler` that aggregates an `HttpMessage` and its following `HttpChunk`s into a single `HttpMessage` with no following `HttpChunk`s. It is useful when you don't want to take care of HTTP messages whose transfer encoding is 'chunked'. Insert this handler after `HttpMessageDecoder` in the `ChannelPipeline`:

       ChannelPipeline p = ...;
       ...
       p.addLast("decoder", new HttpRequestDecoder());
       p.addLast("aggregator", new HttpChunkAggregator(1048576));
       ...
       p.addLast("encoder", new HttpResponseEncoder());
       p.addLast("handler", new HttpRequestHandler());

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler

      `ChannelHandler.Sharable`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpChunkAggregator(int maxContentLength)` Creates a new instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterAdd(ChannelHandlerContext ctx)`
    `void` | `afterRemove(ChannelHandlerContext ctx)`
    `protected void` | `appendToCumulation(ChannelBuffer input)`
    `void` | `beforeAdd(ChannelHandlerContext ctx)`
    `void` | `beforeRemove(ChannelHandlerContext ctx)`
    `int` | `getMaxCumulationBufferComponents()` Returns the maximum number of components in the cumulation buffer.
    `void` | `messageReceived(ChannelHandlerContext ctx, MessageEvent e)` Invoked when a message object (e.g: `ChannelBuffer`) was received from a remote peer.
    `void` | `setMaxCumulationBufferComponents(int maxCumulationBufferComponents)` Sets the maximum number of components in the cumulation buffer.

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

- - ### Field Detail

    - #### DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS

          public static final int DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HttpChunkAggregator

          public HttpChunkAggregator(int maxContentLength)

      Creates a new instance.
      Parameters:
        `maxContentLength` - the maximum length of the aggregated content. If the length of the aggregated content exceeds this value, a `TooLongFrameException` will be raised.

  - ### Method Detail

    - #### getMaxCumulationBufferComponents

          public final int getMaxCumulationBufferComponents()

      Returns the maximum number of components in the cumulation buffer. If the number of the components in the cumulation buffer exceeds this value, the components of the cumulation buffer are consolidated into a single component, involving memory copies. The default value of this property is `DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS`.

    - #### setMaxCumulationBufferComponents

          public final void setMaxCumulationBufferComponents(int maxCumulationBufferComponents)

      Sets the maximum number of components in the cumulation buffer. If the number of the components in the cumulation buffer exceeds this value, the components of the cumulation buffer are consolidated into a single component, involving memory copies. The default value of this property is `DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS` and its minimum allowed value is `2`.

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

    - #### appendToCumulation

          protected void appendToCumulation(ChannelBuffer input)

    - #### beforeAdd

          public void beforeAdd(ChannelHandlerContext ctx)
                         throws Exception

      Specified by:
        `beforeAdd` in interface `LifeCycleAwareChannelHandler`
      Throws:
        `Exception`

    - #### afterAdd

          public void afterAdd(ChannelHandlerContext ctx)
                        throws Exception

      Specified by:
        `afterAdd` in interface `LifeCycleAwareChannelHandler`
      Throws:
        `Exception`

    - #### beforeRemove

          public void beforeRemove(ChannelHandlerContext ctx)
                            throws Exception

      Specified by:
        `beforeRemove` in interface `LifeCycleAwareChannelHandler`
      Throws:
        `Exception`

    - #### afterRemove

          public void afterRemove(ChannelHandlerContext ctx)
                           throws Exception

      Specified by:
        `afterRemove` in interface `LifeCycleAwareChannelHandler`
      Throws:
        `Exception`

Copyright © 2008-2012 The Netty Project. All Rights Reserved.