diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java index ee03184c8c..0a6f9508c5 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java @@ -133,8 +133,12 @@ public interface HttpMessage { long getContentLength(long defaultValue); /** - * Returns {@code true} if and only if the {@code "Transfer-Encoding"} of - * this message is {@code "chunked"}. + * Returns {@code true} if and only if this message does not have any + * content but the {@link HttpChunk}s, which is generated by + * {@link HttpMessageDecoder} consecutively, contain the actual content. + * Please note that {@link HttpMessageDecoder} can split the large content + * into multiple {@link HttpChunk}s to reduce memory consumption even if + * the {@code "Transfer-Encoding"} of this message is not {@code "chunked"}. */ boolean isChunked(); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java index a3fcf536e7..5186f0d950 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java @@ -49,16 +49,43 @@ import org.jboss.netty.handler.codec.replay.ReplayingDecoder; * * {@code maxChunkSize} * The maximum length of the content or each chunk. If the content length - * exceeds this value, the transfer encoding of the decoded message will be - * converted to 'chunked' and the content will be split into multiple - * {@link HttpChunk}s. If the transfer encoding of the HTTP message is - * 'chunked' already, each chunk will be split into smaller chunks if the - * length of the chunk exceeds this value. If you prefer not to handle - * {@link HttpChunk}s in your handler, insert {@link HttpChunkAggregator} - * after this decoder in the {@link ChannelPipeline}. + * (or the length of each chunk) exceeds this value, the content or chunk + * will be split into multiple {@link HttpChunk}s whose length is + * {@code maxChunkSize} at maximum. * * * + *

Chunked Content

+ * + * If the content of an HTTP message is greater than {@code maxChunkSize} or + * the transfer encoding of the HTTP message is 'chunked', this decoder + * generates one {@link HttpMessage} instance and its following + * {@link HttpChunk}s per single HTTP message to avoid excessive memory + * consumption. For example, the following HTTP message: + *
+ * GET / HTTP/1.1
+ * Transfer-Encoding: chunked
+ *
+ * 1a
+ * abcdefghijklmnopqrstuvwxyz
+ * 10
+ * 1234567890abcdef
+ * 0
+ * 
. + * triggers {@link HttpRequestDecoder} to generate 4 objects: + *
    + *
  1. An {@link HttpRequest} whose {@link HttpMessage#isChunked() chunked} + * property is {@code true},
  2. + *
  3. The first {@link HttpChunk} whose content is {@code 'abcdefghijklmnopqrstuvwxyz'},
  4. + *
  5. The second {@link HttpChunk} whose content is {@code '1234567890abcdef'}, and
  6. + *
  7. An {@link HttpChunkTrailer} which marks the end of the content.
  8. + *
+ * + * If you prefer not to handle {@link HttpChunk}s by yourself for your + * convenience, insert {@link HttpChunkAggregator} after this decoder in the + * {@link ChannelPipeline}. However, please note that your server might not + * be as memory efficient as without the aggregator. + * *

Extensibility

* * Please note that this decoder is designed to be extended to implement