public class HttpObjectAggregator extends io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>
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.| Constructor and Description |
|---|
HttpObjectAggregator(int maxContentLength)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
aggregate(FullHttpMessage aggregated,
HttpContent content) |
protected FullHttpMessage |
beginAggregation(HttpMessage start,
io.netty.buffer.ByteBuf content) |
protected long |
contentLength(HttpMessage start) |
protected void |
finishAggregation(FullHttpMessage aggregated) |
protected void |
handleOversizedMessage(io.netty.channel.ChannelHandlerContext ctx,
HttpMessage oversized) |
protected boolean |
hasContentLength(HttpMessage start) |
protected boolean |
isAggregated(HttpObject msg) |
protected boolean |
isContentMessage(HttpObject msg) |
protected boolean |
isLastContentMessage(HttpContent msg) |
protected boolean |
isStartMessage(HttpObject msg) |
protected Object |
newContinueResponse(HttpMessage start) |
acceptInboundMessage, channelInactive, ctx, decode, handlerAdded, handlerRemoved, isHandlingOversizedMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponentspublic HttpObjectAggregator(int maxContentLength)
maxContentLength - the maximum length of the aggregated content.
If the length of the aggregated content exceeds this value,
handleOversizedMessage(ChannelHandlerContext, HttpMessage)
will be called.protected boolean isStartMessage(HttpObject msg) throws Exception
isStartMessage in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected boolean isContentMessage(HttpObject msg) throws Exception
isContentMessage in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected boolean isLastContentMessage(HttpContent msg) throws Exception
isLastContentMessage in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected boolean isAggregated(HttpObject msg) throws Exception
isAggregated in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected boolean hasContentLength(HttpMessage start) throws Exception
hasContentLength in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected long contentLength(HttpMessage start) throws Exception
contentLength in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected Object newContinueResponse(HttpMessage start) throws Exception
newContinueResponse in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected FullHttpMessage beginAggregation(HttpMessage start, io.netty.buffer.ByteBuf content) throws Exception
beginAggregation in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected void aggregate(FullHttpMessage aggregated, HttpContent content) throws Exception
aggregate in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected void finishAggregation(FullHttpMessage aggregated) throws Exception
finishAggregation in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>Exceptionprotected void handleOversizedMessage(io.netty.channel.ChannelHandlerContext ctx,
HttpMessage oversized)
throws Exception
handleOversizedMessage in class io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>ExceptionCopyright © 2008–2015 The Netty Project. All rights reserved.