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", 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 ChannelBuffer
private ChannelHandlerContext
private HttpMessage
static final int
private final int
private int
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
protected void
appendToCumulation
(ChannelBuffer input) void
void
final int
Returns the maximum number of components in the cumulation buffer.void
Invoked when a message object (e.g:ChannelBuffer
) was received from a remote peer.final 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
-
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, aTooLongFrameException
will 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_COMPONENTS
and its minimum allowed value is2
. -
messageReceived
Description copied from class:SimpleChannelUpstreamHandler
Invoked when a message object (e.g:ChannelBuffer
) was received from a remote peer.- Overrides:
messageReceived
in classSimpleChannelUpstreamHandler
- Throws:
Exception
-
appendToCumulation
-
beforeAdd
- Specified by:
beforeAdd
in interfaceLifeCycleAwareChannelHandler
- Throws:
Exception
-
afterAdd
- Specified by:
afterAdd
in interfaceLifeCycleAwareChannelHandler
- Throws:
Exception
-
beforeRemove
- Specified by:
beforeRemove
in interfaceLifeCycleAwareChannelHandler
- Throws:
Exception
-
afterRemove
- Specified by:
afterRemove
in interfaceLifeCycleAwareChannelHandler
- Throws:
Exception
-