public class HttpObjectAggregator extends io.netty.handler.codec.MessageToMessageDecoder<HttpObject>
ChannelHandler that aggregates an HttpMessage
and its following HttpContents into a single FullHttpRequest
or FullHttpResponse (depending on if it used to handle requests or responses)
with no following HttpContents. It is useful when you don't want to take
care of HTTP messages whose transfer encoding is 'chunked'. Insert this
handler after HttpObjectDecoder in the ChannelPipeline:
Be aware that you need to have theChannelPipelinep = ...; ... p.addLast("encoder", newHttpResponseEncoder()); p.addLast("decoder", newHttpRequestDecoder()); p.addLast("aggregator", newHttpObjectAggregator(1048576)); ... p.addLast("handler", new HttpRequestHandler());
HttpResponseEncoder or HttpRequestEncoder
before the HttpObjectAggregator in the ChannelPipeline.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS |
| Constructor and Description |
|---|
HttpObjectAggregator(int maxContentLength)
Creates a new instance.
|
HttpObjectAggregator(int maxContentLength,
boolean closeOnExpectationFailed)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
protected void |
decode(io.netty.channel.ChannelHandlerContext ctx,
HttpObject msg,
List<Object> out) |
int |
getMaxCumulationBufferComponents()
Returns the maximum number of components in the cumulation buffer.
|
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
void |
handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) |
void |
setMaxCumulationBufferComponents(int maxCumulationBufferComponents)
Sets the maximum number of components in the cumulation buffer.
|
acceptInboundMessage, channelReadpublic static final int DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
public HttpObjectAggregator(int maxContentLength)
maxContentLength - the maximum length of the aggregated content in bytes.
If the length of the aggregated content exceeds this value,
a TooLongFrameException will be raised.public HttpObjectAggregator(int maxContentLength,
boolean closeOnExpectationFailed)
maxContentLength - the maximum length of the aggregated content in bytes.
If the length of the aggregated content exceeds this value,
a TooLongFrameException will be raised.closeOnExpectationFailed - If a 100-continue response is detected but the content length is too large
then true means close the connection. otherwise the connection will remain open and data will be
consumed and discarded until the next request is received.public final int getMaxCumulationBufferComponents()
DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS.public final void setMaxCumulationBufferComponents(int maxCumulationBufferComponents)
DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
and its minimum allowed value is 2.protected void decode(io.netty.channel.ChannelHandlerContext ctx,
HttpObject msg,
List<Object> out)
throws Exception
decode in class io.netty.handler.codec.MessageToMessageDecoder<HttpObject>Exceptionpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerAdded in interface io.netty.channel.ChannelHandlerhandlerAdded in class io.netty.channel.ChannelHandlerAdapterExceptionCopyright © 2008–2016 The Netty Project. All rights reserved.