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 HttpChunks into a single HttpMessage with
no following HttpChunks. 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:
ChannelPipelinep = ...; ... p.addLast("decoder", newHttpRequestDecoder()); p.addLast("aggregator", newHttpChunkAggregator(1048576)); ... p.addLast("encoder", newHttpResponseEncoder()); p.addLast("handler", new HttpRequestHandler());
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ChannelBufferprivate ChannelHandlerContextprivate HttpMessagestatic final intprivate final intprivate intprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidprotected voidappendToCumulation(ChannelBuffer input) voidvoidfinal intReturns the maximum number of components in the cumulation buffer.voidInvoked when a message object (e.g:ChannelBuffer) was received from a remote peer.final voidsetMaxCumulationBufferComponents(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
-
Field Details
-
DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
public static final int DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS- See Also:
-
CONTINUE
-
maxContentLength
private final int maxContentLength -
currentMessage
-
tooLongFrameFound
private boolean tooLongFrameFound -
ctx
-
maxCumulationBufferComponents
private int maxCumulationBufferComponents
-
-
Constructor Details
-
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, aTooLongFrameExceptionwill be raised.
-
-
Method Details
-
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 isDEFAULT_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 isDEFAULT_MAX_COMPOSITEBUFFER_COMPONENTSand its minimum allowed value is2. -
messageReceived
Description copied from class:SimpleChannelUpstreamHandlerInvoked when a message object (e.g:ChannelBuffer) was received from a remote peer.- Overrides:
messageReceivedin classSimpleChannelUpstreamHandler- Throws:
Exception
-
appendToCumulation
-
beforeAdd
- Specified by:
beforeAddin interfaceLifeCycleAwareChannelHandler- Throws:
Exception
-
afterAdd
- Specified by:
afterAddin interfaceLifeCycleAwareChannelHandler- Throws:
Exception
-
beforeRemove
- Specified by:
beforeRemovein interfaceLifeCycleAwareChannelHandler- Throws:
Exception
-
afterRemove
- Specified by:
afterRemovein interfaceLifeCycleAwareChannelHandler- Throws:
Exception
-