ch.mimo.netty.handler.codec.icap
Class IcapChunkAggregator

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by ch.mimo.netty.handler.codec.icap.IcapChunkAggregator
All Implemented Interfaces:
org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class IcapChunkAggregator
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler

This ICAP chunk aggregator will combine an received ICAP message with all body chunks. the body is the to be found attached to the correct HTTP request or response instance within the ICAP message. In case when a Preview IcapRequest is received with an early chunk termination the preview indication and header are removed entirely from the message. This is done because a preview message with an early content termination is in essence nothing else than a full message. The reader index of an HTTP content ChannelBuffer can be reset to 0 via a dedicated constructor in order to handle preview aggregation. This is done in order to allow server implementations to handle preview messages properly. A preview message is aggregated with the 100 Continue response from the client and the buffer will be therefore reset to 0 so that the server handler can read the entire message.

Author:
Michael Mimo Moratti (mimo@mimo.ch)
See Also:
IcapChunkSeparator

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
IcapChunkAggregator(long maxContentLength)
           
IcapChunkAggregator(long maxContentLength, boolean resetReaderIndex)
          Constructor that allows to change the preview body update behavior to reset the HTTP message body channel reader index when receiving the rest of the body after a 100 Continue.
 
Method Summary
static org.jboss.netty.buffer.ChannelBuffer extractHttpBodyContentFromIcapMessage(IcapMessage message)
          Convenience method to retrieve a HTTP request,response or an ICAP options response body from an aggregated IcapMessage.
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent e)
           
 
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

IcapChunkAggregator

public IcapChunkAggregator(long maxContentLength)
Parameters:
maxContentLength - defines the maximum length of the body content that is allowed. If the length is exceeded an exception is thrown.

IcapChunkAggregator

public IcapChunkAggregator(long maxContentLength,
                           boolean resetReaderIndex)
Constructor that allows to change the preview body update behavior to reset the HTTP message body channel reader index when receiving the rest of the body after a 100 Continue.

Parameters:
maxContentLength - defines the maximum length of the body content that is allowed.
resetReaderIndex - defines if the HTTP message reader index should be reset after adding more data to it.
Method Detail

extractHttpBodyContentFromIcapMessage

public static org.jboss.netty.buffer.ChannelBuffer extractHttpBodyContentFromIcapMessage(IcapMessage message)
Convenience method to retrieve a HTTP request,response or an ICAP options response body from an aggregated IcapMessage.

Parameters:
message -
Returns:
null or @see ChannelBuffer if a body exists.

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.MessageEvent e)
                     throws Exception
Overrides:
messageReceived in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception


Copyright © 2011-2012. All Rights Reserved.