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 HttpResponseDecoder in the ChannelPipeline if being used to handle
responses, or after HttpRequestDecoder and HttpResponseEncoder in the
ChannelPipeline if being used to handle requests.
ChannelPipelinep = ...; ... p.addLast("decoder", newHttpRequestDecoder()); p.addLast("encoder", newHttpResponseEncoder()); p.addLast("aggregator", newHttpObjectAggregator(1048576)); ... p.addLast("handler", new HttpRequestHandler());
For convenience, consider putting a HttpServerCodec before the HttpObjectAggregator
as it functions as both a HttpRequestDecoder and a HttpResponseEncoder.
HttpObjectAggregator may end up sending a HttpResponse:
| Response Status | Condition When Sent |
|---|---|
| 100 Continue | A '100-continue' expectation is received and the 'content-length' doesn't exceed maxContentLength |
| 417 Expectation Failed | A '100-continue' expectation is received and the 'content-length' exceeds maxContentLength |
| 413 Request Entity Too Large | Either the 'content-length' or the bytes received so far exceed maxContentLength |
FullHttpRequest, FullHttpResponse, HttpResponseDecoder, HttpServerCodec
| Modifier and Type | Class and Description |
|---|---|
| private abstract static class | |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private static final FullHttpResponse | |
| private static final FullHttpResponse | |
| private static final InternalLogger | |
| private static final FullHttpResponse | |
| private static final FullHttpResponse |
| Access | Constructor and Description |
|---|---|
| public | HttpObjectAggregator(int
the maximum length of the aggregated content in bytes.
If the length of the aggregated content exceeds this value,
maxContentLength)handleOversizedMessage(ChannelHandlerContext, HttpMessage) will be called.Creates a new instance. |
| public | HttpObjectAggregator(int
the maximum length of the aggregated content in bytes.
If the length of the aggregated content exceeds this value,
maxContentLength, boolean handleOversizedMessage(ChannelHandlerContext, HttpMessage) will be called.If a 100-continue response is detected but the content length is too large
then closeOnExpectationFailed)true means close the connection. otherwise the connection will remain open and data will be
consumed and discarded until the next request is received.Creates a new instance. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | aggregate(FullHttpMessage aggregated, HttpContent content)
Overrides io. |
| protected FullHttpMessage | beginAggregation(HttpMessage start, ByteBuf content)
Implements abstract io. |
| protected boolean | closeAfterContinueResponse(Object
The return value from msg)newContinueResponse(Object, int, ChannelPipeline).Implements abstract io. newContinueResponse(Object, int, ChannelPipeline) is written.
|
| private static Object | |
| protected void | finishAggregation(FullHttpMessage aggregated)
Overrides io. aggregated message is about to be passed to the next handler in the pipeline.
|
| protected void | handleOversizedMessage(final ChannelHandlerContext ctx, HttpMessage
the accumulated message up to this point, whose type is oversized)S or OOverrides io. |
| protected boolean | ignoreContentAfterContinueResponse(Object
The return value from msg)newContinueResponse(Object, int, ChannelPipeline).Implements abstract io. |
| protected boolean | isAggregated(HttpObject msg)
Implements abstract io. true if and only if the specified message is already aggregated.
|
| protected boolean | isContentLengthInvalid(HttpMessage
The message which may indicate the content length. start, int The maximum allowed content length. maxContentLength)Implements abstract io. start's content length is known, and if it greater than
maxContentLength.
|
| protected boolean | isContentMessage(HttpObject msg)
Implements abstract io. true if and only if the specified message is a content message.
|
| protected boolean | isLastContentMessage(HttpContent msg)
Implements abstract io. true if and only if the specified message is the last content message.
|
| protected boolean | isStartMessage(HttpObject msg)
Implements abstract io. true if and only if the specified message is a start message.
|
| protected Object | newContinueResponse(HttpMessage start, int maxContentLength, ChannelPipeline pipeline)
Implements abstract io. |