Repository: netty/netty
Issue: [Netty 5]: Remove the HttpObjectDecoder `maxChunkSize` parameter in Netty 5.x
Labels: cleanup

This is a cleanup request for Netty 5.x. The family of HTTP codecs passes a parameter called `maxChunkSize` to `HttpObjectDecoder` which limits the size of chunks that decoder will emit. Note that this doesn't cause the HTTP dispatch to switch from a `FullHttpMessage` to a regular message or to avoid buffering data, it only means that any already buffered content data may be split into smaller messages if its size exceeds the limit. For example, if the raw `buffer` has 16kb of message content but the `maxChunkSize` is 2kb, it will simply split the content into 8*2kb `HttpContent` instances instead of a single 16kb instance.

The current value of this is questionable and was likely more useful in the Netty3 model when the decoder may have emitted fully buffered messages.

### Netty version
4.1.x

Issue comments:
For the reference, this is us unsetting the limit in Finagle: https://github.com/twitter/finagle/commit/990c8650366e5374ea062c753a4628c5971fc40e
@bryce-anderson @vkostyukov agree... @Scottmitch also told me at some point he wanted to remove it. 
@bryce-anderson want to do a PR against the master branch ?
@normanmaurer, I'll take this one, probably early next week.
@bryce-anderson thanks a lot!

Pull request review comments:
Aren't `chunkSize` already an `int`?
No, it's a `long`. The name is kind of misleading, it might be better as `remainingContent` or something, though that then becomes misleading for `transfer-encoding: chunked` content...

Patch that resolved the issue:
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java
index dd1da34742b..8770202d0d1 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java
@@ -61,40 +61,40 @@ public final class HttpClientCodec extends CombinedChannelDuplexHandler<HttpResp
      * {@code maxChunkSize (8192)}).
      */
     public HttpClientCodec() {
-        this(4096, 8192, 8192, false);
+        this(4096, 8192, false);
     }
 
     /**
      * Creates a new instance with the specified decoder options.
      */
-    public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) {
-        this(maxInitialLineLength, maxHeaderSize, maxChunkSize, false);
+    public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize) {
+        this(maxInitialLineLength, maxHeaderSize, false);
     }
 
     /**
      * Creates a new instance with the specified decoder options.
      */
     public HttpClientCodec(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse) {
-        this(maxInitialLineLength, maxHeaderSize, maxChunkSize, failOnMissingResponse, true);
+            int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse) {
+        this(maxInitialLineLength, maxHeaderSize, failOnMissingResponse, true);
     }
 
     /**
      * Creates a new instance with the specified decoder options.
      */
     public HttpClientCodec(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse,
+            int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse,
             boolean validateHeaders) {
-        this(maxInitialLineLength, maxHeaderSize, maxChunkSize, failOnMissingResponse, validateHeaders, false);
+        this(maxInitialLineLength, maxHeaderSize, failOnMissingResponse, validateHeaders, false);
     }
 
     /**
      * Creates a new instance with the specified decoder options.
      */
     public HttpClientCodec(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse,
+            int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse,
             boolean validateHeaders, boolean parseHttpAfterConnectRequest) {
-        init(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders), new Encoder());
+        init(new Decoder(maxInitialLineLength, maxHeaderSize, validateHeaders), new Encoder());
         this.failOnMissingResponse = failOnMissingResponse;
         this.parseHttpAfterConnectRequest = parseHttpAfterConnectRequest;
     }
@@ -115,7 +115,7 @@ public HttpClientCodec(
     public HttpClientCodec(
             int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse,
             boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest) {
-        init(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders, initialBufferSize),
+        init(new Decoder(maxInitialLineLength, maxHeaderSize, validateHeaders, initialBufferSize),
              new Encoder());
         this.parseHttpAfterConnectRequest = parseHttpAfterConnectRequest;
         this.failOnMissingResponse = failOnMissingResponse;
@@ -177,13 +177,13 @@ protected void encode(
     }
 
     private final class Decoder extends HttpResponseDecoder {
-        Decoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders) {
-            super(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders);
+        Decoder(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders) {
+            super(maxInitialLineLength, maxHeaderSize, validateHeaders);
         }
 
-        Decoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders,
+        Decoder(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders,
                 int initialBufferSize) {
-            super(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders, initialBufferSize);
+            super(maxInitialLineLength, maxHeaderSize, validateHeaders, initialBufferSize);
         }
 
         @Override
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java
index af1d642a039..d3546d82164 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java
@@ -102,7 +102,6 @@
 public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
     private static final String EMPTY_VALUE = "";
 
-    private final int maxChunkSize;
     private final boolean chunkedSupported;
     protected final boolean validateHeaders;
     private final HeaderParser headerParser;
@@ -145,28 +144,28 @@ private enum State {
      * {@code maxChunkSize (8192)}.
      */
     protected HttpObjectDecoder() {
-        this(4096, 8192, 8192, true);
+        this(4096, 8192, true);
     }
 
     /**
      * Creates a new instance with the specified parameters.
      */
     protected HttpObjectDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported) {
-        this(maxInitialLineLength, maxHeaderSize, maxChunkSize, chunkedSupported, true);
+            int maxInitialLineLength, int maxHeaderSize, boolean chunkedSupported) {
+        this(maxInitialLineLength, maxHeaderSize, chunkedSupported, true);
     }
 
     /**
      * Creates a new instance with the specified parameters.
      */
     protected HttpObjectDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize,
+            int maxInitialLineLength, int maxHeaderSize,
             boolean chunkedSupported, boolean validateHeaders) {
-        this(maxInitialLineLength, maxHeaderSize, maxChunkSize, chunkedSupported, validateHeaders, 128);
+        this(maxInitialLineLength, maxHeaderSize, chunkedSupported, validateHeaders, 128);
     }
 
     protected HttpObjectDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize,
+            int maxInitialLineLength, int maxHeaderSize,
             boolean chunkedSupported, boolean validateHeaders, int initialBufferSize) {
         if (maxInitialLineLength <= 0) {
             throw new IllegalArgumentException(
@@ -178,15 +177,9 @@ protected HttpObjectDecoder(
                     "maxHeaderSize must be a positive integer: " +
                     maxHeaderSize);
         }
-        if (maxChunkSize <= 0) {
-            throw new IllegalArgumentException(
-                    "maxChunkSize must be a positive integer: " +
-                    maxChunkSize);
-        }
         AppendableCharSequence seq = new AppendableCharSequence(initialBufferSize);
         lineParser = new LineParser(seq, maxInitialLineLength);
         headerParser = new HeaderParser(seq, maxHeaderSize);
-        this.maxChunkSize = maxChunkSize;
         this.chunkedSupported = chunkedSupported;
         this.validateHeaders = validateHeaders;
     }
@@ -278,7 +271,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
         }
         case READ_VARIABLE_LENGTH_CONTENT: {
             // Keep reading data as a chunk until the end of connection is reached.
-            int toRead = Math.min(buffer.readableBytes(), maxChunkSize);
+            int toRead = buffer.readableBytes();
             if (toRead > 0) {
                 ByteBuf content = buffer.readRetainedSlice(toRead);
                 out.add(new DefaultHttpContent(content));
@@ -286,7 +279,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
             return;
         }
         case READ_FIXED_LENGTH_CONTENT: {
-            int readLimit = buffer.readableBytes();
+            int toRead = buffer.readableBytes();
 
             // Check if the buffer is readable first as we use the readable byte count
             // to create the HttpChunk. This is needed as otherwise we may end up with
@@ -294,14 +287,14 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
             // handled like it is the last HttpChunk.
             //
             // See https://github.com/netty/netty/issues/433
-            if (readLimit == 0) {
+            if (toRead == 0) {
                 return;
             }
 
-            int toRead = Math.min(readLimit, maxChunkSize);
             if (toRead > chunkSize) {
                 toRead = (int) chunkSize;
             }
+
             ByteBuf content = buffer.readRetainedSlice(toRead);
             chunkSize -= toRead;
 
@@ -337,7 +330,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
         }
         case READ_CHUNKED_CONTENT: {
             assert chunkSize <= Integer.MAX_VALUE;
-            int toRead = Math.min((int) chunkSize, maxChunkSize);
+            int toRead = (int) chunkSize;
             toRead = Math.min(toRead, buffer.readableBytes());
             if (toRead == 0) {
                 return;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpRequestDecoder.java
index 24252c73587..1be6cf52e36 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpRequestDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpRequestDecoder.java
@@ -66,19 +66,19 @@ public HttpRequestDecoder() {
      * Creates a new instance with the specified parameters.
      */
     public HttpRequestDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) {
-        super(maxInitialLineLength, maxHeaderSize, maxChunkSize, true);
+            int maxInitialLineLength, int maxHeaderSize) {
+        super(maxInitialLineLength, maxHeaderSize, true);
     }
 
     public HttpRequestDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders) {
-        super(maxInitialLineLength, maxHeaderSize, maxChunkSize, true, validateHeaders);
+            int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders) {
+        super(maxInitialLineLength, maxHeaderSize, true, validateHeaders);
     }
 
     public HttpRequestDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders,
+            int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders,
             int initialBufferSize) {
-        super(maxInitialLineLength, maxHeaderSize, maxChunkSize, true, validateHeaders, initialBufferSize);
+        super(maxInitialLineLength, maxHeaderSize, true, validateHeaders, initialBufferSize);
     }
 
     @Override
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseDecoder.java
index 21491971ef3..ede22f4eeb0 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseDecoder.java
@@ -97,19 +97,19 @@ public HttpResponseDecoder() {
      * Creates a new instance with the specified parameters.
      */
     public HttpResponseDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) {
-        super(maxInitialLineLength, maxHeaderSize, maxChunkSize, true);
+            int maxInitialLineLength, int maxHeaderSize) {
+        super(maxInitialLineLength, maxHeaderSize, true);
     }
 
     public HttpResponseDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders) {
-        super(maxInitialLineLength, maxHeaderSize, maxChunkSize, true, validateHeaders);
+            int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders) {
+        super(maxInitialLineLength, maxHeaderSize, true, validateHeaders);
     }
 
     public HttpResponseDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders,
+            int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders,
             int initialBufferSize) {
-        super(maxInitialLineLength, maxHeaderSize, maxChunkSize, true, validateHeaders, initialBufferSize);
+        super(maxInitialLineLength, maxHeaderSize, true, validateHeaders, initialBufferSize);
     }
 
     @Override
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java
index 4e8d61361b2..f72484e4f21 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java
@@ -41,32 +41,32 @@ public final class HttpServerCodec extends CombinedChannelDuplexHandler<HttpRequ
      * {@code maxChunkSize (8192)}).
      */
     public HttpServerCodec() {
-        this(4096, 8192, 8192);
+        this(4096, 8192);
     }
 
     /**
      * Creates a new instance with the specified decoder options.
      */
-    public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) {
-        init(new HttpServerRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize),
+    public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize) {
+        init(new HttpServerRequestDecoder(maxInitialLineLength, maxHeaderSize),
                 new HttpServerResponseEncoder());
     }
 
     /**
      * Creates a new instance with the specified decoder options.
      */
-    public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders) {
-        init(new HttpServerRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders),
+    public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders) {
+        init(new HttpServerRequestDecoder(maxInitialLineLength, maxHeaderSize, validateHeaders),
                 new HttpServerResponseEncoder());
     }
 
     /**
      * Creates a new instance with the specified decoder options.
      */
-    public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders,
+    public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders,
                            int initialBufferSize) {
         init(
-          new HttpServerRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize,
+          new HttpServerRequestDecoder(maxInitialLineLength, maxHeaderSize,
                   validateHeaders, initialBufferSize),
           new HttpServerResponseEncoder());
     }
@@ -81,18 +81,18 @@ public void upgradeFrom(ChannelHandlerContext ctx) {
     }
 
     private final class HttpServerRequestDecoder extends HttpRequestDecoder {
-        public HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) {
-            super(maxInitialLineLength, maxHeaderSize, maxChunkSize);
+        public HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize) {
+            super(maxInitialLineLength, maxHeaderSize);
         }
 
-        public HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize,
+        public HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize,
                                         boolean validateHeaders) {
-            super(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders);
+            super(maxInitialLineLength, maxHeaderSize, validateHeaders);
         }
 
-        public HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize,
+        public HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize,
                                         boolean validateHeaders, int initialBufferSize) {
-            super(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders, initialBufferSize);
+            super(maxInitialLineLength, maxHeaderSize, validateHeaders, initialBufferSize);
         }
 
         @Override
diff --git a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspDecoder.java
index acc028978f0..cbab65e7f68 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspDecoder.java
@@ -106,7 +106,7 @@ public RtspDecoder() {
     public RtspDecoder(final int maxInitialLineLength,
                        final int maxHeaderSize,
                        final int maxContentLength) {
-        super(maxInitialLineLength, maxHeaderSize, maxContentLength * 2, false);
+        super(maxInitialLineLength, maxHeaderSize, false);
     }
 
     /**
@@ -122,7 +122,6 @@ public RtspDecoder(final int maxInitialLineLength,
                        final boolean validateHeaders) {
         super(maxInitialLineLength,
               maxHeaderSize,
-              maxContentLength * 2,
               false,
               validateHeaders);
     }
diff --git a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspObjectDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspObjectDecoder.java
index e52c0ce51e5..e19472193b3 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspObjectDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspObjectDecoder.java
@@ -55,23 +55,22 @@ public abstract class RtspObjectDecoder extends HttpObjectDecoder {
 
     /**
      * Creates a new instance with the default
-     * {@code maxInitialLineLength (4096)}, {@code maxHeaderSize (8192)}, and
-     * {@code maxContentLength (8192)}.
+     * {@code maxInitialLineLength (4096)}, {@code maxHeaderSize (8192)}.
      */
     protected RtspObjectDecoder() {
-        this(4096, 8192, 8192);
+        this(4096, 8192);
     }
 
     /**
      * Creates a new instance with the specified parameters.
      */
-    protected RtspObjectDecoder(int maxInitialLineLength, int maxHeaderSize, int maxContentLength) {
-        super(maxInitialLineLength, maxHeaderSize, maxContentLength * 2, false);
+    protected RtspObjectDecoder(int maxInitialLineLength, int maxHeaderSize) {
+        super(maxInitialLineLength, maxHeaderSize, false);
     }
 
     protected RtspObjectDecoder(
-            int maxInitialLineLength, int maxHeaderSize, int maxContentLength, boolean validateHeaders) {
-        super(maxInitialLineLength, maxHeaderSize, maxContentLength * 2, false, validateHeaders);
+            int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders) {
+        super(maxInitialLineLength, maxHeaderSize, false, validateHeaders);
     }
 
     @Override


Test patch:
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java
index 16a6eff29de..416e4d6749e 100644
--- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java
@@ -59,7 +59,7 @@ public class HttpClientCodecTest {
 
     @Test
     public void testConnectWithResponseContent() {
-        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
+        HttpClientCodec codec = new HttpClientCodec(4096, 8192, true);
         EmbeddedChannel ch = new EmbeddedChannel(codec);
 
         sendRequestAndReadResponse(ch, HttpMethod.CONNECT, RESPONSE);
@@ -68,7 +68,7 @@ public void testConnectWithResponseContent() {
 
     @Test
     public void testFailsNotOnRequestResponseChunked() {
-        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
+        HttpClientCodec codec = new HttpClientCodec(4096, 8192, true);
         EmbeddedChannel ch = new EmbeddedChannel(codec);
 
         sendRequestAndReadResponse(ch, HttpMethod.GET, CHUNKED_RESPONSE);
@@ -77,7 +77,7 @@ public void testFailsNotOnRequestResponseChunked() {
 
     @Test
     public void testFailsOnMissingResponse() {
-        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
+        HttpClientCodec codec = new HttpClientCodec(4096, 8192, true);
         EmbeddedChannel ch = new EmbeddedChannel(codec);
 
         assertTrue(ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
@@ -95,7 +95,7 @@ public void testFailsOnMissingResponse() {
 
     @Test
     public void testFailsOnIncompleteChunkedResponse() {
-        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
+        HttpClientCodec codec = new HttpClientCodec(4096, 8192, true);
         EmbeddedChannel ch = new EmbeddedChannel(codec);
 
         ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/"));
@@ -130,7 +130,7 @@ public void testServerCloseSocketInputProvidesData() throws InterruptedException
                 @Override
                 protected void initChannel(Channel ch) throws Exception {
                     // Don't use the HttpServerCodec, because we don't want to have content-length or anything added.
-                    ch.pipeline().addLast(new HttpRequestDecoder(4096, 8192, 8192, true));
+                    ch.pipeline().addLast(new HttpRequestDecoder(4096, 8192, true));
                     ch.pipeline().addLast(new HttpObjectAggregator(4096));
                     ch.pipeline().addLast(new SimpleChannelInboundHandler<FullHttpRequest>() {
                         @Override
@@ -174,7 +174,7 @@ public void operationComplete(ChannelFuture future) throws Exception {
             cb.handler(new ChannelInitializer<Channel>() {
                 @Override
                 protected void initChannel(Channel ch) throws Exception {
-                    ch.pipeline().addLast(new HttpClientCodec(4096, 8192, 8192, true, true));
+                    ch.pipeline().addLast(new HttpClientCodec(4096, 8192, true, true));
                     ch.pipeline().addLast(new HttpObjectAggregator(4096));
                     ch.pipeline().addLast(new SimpleChannelInboundHandler<FullHttpResponse>() {
                         @Override
@@ -212,7 +212,7 @@ public void testPassThroughAfterConnect() throws Exception {
     }
 
     private static void testAfterConnect(final boolean parseAfterConnect) throws Exception {
-        EmbeddedChannel ch = new EmbeddedChannel(new HttpClientCodec(4096, 8192, 8192, true, true, parseAfterConnect));
+        EmbeddedChannel ch = new EmbeddedChannel(new HttpClientCodec(4096, 8192, true, true, parseAfterConnect));
 
         Consumer connectResponseConsumer = new Consumer();
         sendRequestAndReadResponse(ch, HttpMethod.CONNECT, EMPTY_RESPONSE, connectResponseConsumer);
@@ -284,7 +284,7 @@ public void testDecodesFinalResponseAfterSwitchingProtocols() {
                 "Connection: Upgrade\r\n" +
                 "Upgrade: TLS/1.2, HTTP/1.1\r\n\r\n";
 
-        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
+        HttpClientCodec codec = new HttpClientCodec(4096, 8192, true);
         EmbeddedChannel ch = new EmbeddedChannel(codec, new HttpObjectAggregator(1024));
 
         HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/");
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java
index 7a27a4c08ac..b7ea6df628e 100644
--- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java
@@ -284,7 +284,7 @@ public void testRequestContentLength1() {
         // or removes it completely (handlers down the chain must rely on LastHttpContent object)
 
         // force content to be in more than one chunk (5 bytes/chunk)
-        HttpRequestDecoder decoder = new HttpRequestDecoder(4096, 4096, 5);
+        HttpRequestDecoder decoder = new HttpRequestDecoder(4096, 4096);
         HttpContentDecoder decompressor = new HttpContentDecompressor();
         EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor);
         String headers = "POST / HTTP/1.1\r\n" +
@@ -313,7 +313,7 @@ public void testRequestContentLength2() {
         // case 2: if HttpObjectAggregator is down the chain, then correct Content-Length header must be set
 
         // force content to be in more than one chunk (5 bytes/chunk)
-        HttpRequestDecoder decoder = new HttpRequestDecoder(4096, 4096, 5);
+        HttpRequestDecoder decoder = new HttpRequestDecoder(4096, 4096);
         HttpContentDecoder decompressor = new HttpContentDecompressor();
         HttpObjectAggregator aggregator = new HttpObjectAggregator(1024);
         EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor, aggregator);
@@ -345,7 +345,7 @@ public void testResponseContentLength1() {
         // or removes it completely (handlers down the chain must rely on LastHttpContent object)
 
         // force content to be in more than one chunk (5 bytes/chunk)
-        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096, 5);
+        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096);
         HttpContentDecoder decompressor = new HttpContentDecompressor();
         EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor);
         String headers = "HTTP/1.1 200 OK\r\n" +
@@ -377,7 +377,7 @@ public void testResponseContentLength2() {
         // case 2: if HttpObjectAggregator is down the chain, then correct Content-Length header must be set
 
         // force content to be in more than one chunk (5 bytes/chunk)
-        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096, 5);
+        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096);
         HttpContentDecoder decompressor = new HttpContentDecompressor();
         HttpObjectAggregator aggregator = new HttpObjectAggregator(1024);
         EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor, aggregator);
@@ -405,7 +405,7 @@ public void testResponseContentLength2() {
     @Test
     public void testFullHttpRequest() {
         // test that ContentDecoder can be used after the ObjectAggregator
-        HttpRequestDecoder decoder = new HttpRequestDecoder(4096, 4096, 5);
+        HttpRequestDecoder decoder = new HttpRequestDecoder(4096, 4096);
         HttpObjectAggregator aggregator = new HttpObjectAggregator(1024);
         HttpContentDecoder decompressor = new HttpContentDecompressor();
         EmbeddedChannel channel = new EmbeddedChannel(decoder, aggregator, decompressor);
@@ -432,7 +432,7 @@ public void testFullHttpRequest() {
     @Test
     public void testFullHttpResponse() {
         // test that ContentDecoder can be used after the ObjectAggregator
-        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096, 5);
+        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096);
         HttpObjectAggregator aggregator = new HttpObjectAggregator(1024);
         HttpContentDecoder decompressor = new HttpContentDecompressor();
         EmbeddedChannel channel = new EmbeddedChannel(decoder, aggregator, decompressor);
@@ -460,7 +460,7 @@ public void testFullHttpResponse() {
     @Test
     public void testFullHttpResponseEOF() {
         // test that ContentDecoder can be used after the ObjectAggregator
-        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096, 5);
+        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096);
         HttpContentDecoder decompressor = new HttpContentDecompressor();
         EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor);
         String headers = "HTTP/1.1 200 OK\r\n" +
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestDecoderTest.java
index 45720631c40..7005bfab4dd 100644
--- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestDecoderTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestDecoderTest.java
@@ -297,7 +297,7 @@ public void testMessagesSplitBetweenMultipleBuffers() {
 
     @Test
     public void testTooLargeInitialLine() {
-        EmbeddedChannel channel = new EmbeddedChannel(new HttpRequestDecoder(10, 1024, 1024));
+        EmbeddedChannel channel = new EmbeddedChannel(new HttpRequestDecoder(10, 1024));
         String requestStr = "GET /some/path HTTP/1.1\r\n" +
                 "Host: localhost1\r\n\r\n";
 
@@ -310,7 +310,7 @@ public void testTooLargeInitialLine() {
 
     @Test
     public void testTooLargeHeaders() {
-        EmbeddedChannel channel = new EmbeddedChannel(new HttpRequestDecoder(1024, 10, 1024));
+        EmbeddedChannel channel = new EmbeddedChannel(new HttpRequestDecoder(1024, 10));
         String requestStr = "GET /some/path HTTP/1.1\r\n" +
                 "Host: localhost1\r\n\r\n";
 
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java
index 017dbd5ff94..99707a7e1f7 100644
--- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java
@@ -49,7 +49,7 @@ public class HttpResponseDecoderTest {
     public void testMaxHeaderSize1() {
         final int maxHeaderSize = 8192;
 
-        final EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(4096, maxHeaderSize, 8192));
+        final EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(4096, maxHeaderSize));
         final char[] bytes = new char[maxHeaderSize / 2 - 2];
         Arrays.fill(bytes, 'a');
 
@@ -81,7 +81,7 @@ public void testMaxHeaderSize1() {
     public void testMaxHeaderSize2() {
         final int maxHeaderSize = 8192;
 
-        final EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(4096, maxHeaderSize, 8192));
+        final EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(4096, maxHeaderSize));
         final char[] bytes = new char[maxHeaderSize / 2 - 2];
         Arrays.fill(bytes, 'a');
 
@@ -146,55 +146,6 @@ public void testResponseChunked() {
         assertNull(ch.readInbound());
     }
 
-    @Test
-    public void testResponseChunkedExceedMaxChunkSize() {
-        EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(4096, 8192, 32));
-        ch.writeInbound(
-                Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n", CharsetUtil.US_ASCII));
-
-        HttpResponse res = ch.readInbound();
-        assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
-        assertThat(res.status(), is(HttpResponseStatus.OK));
-
-        byte[] data = new byte[64];
-        for (int i = 0; i < data.length; i++) {
-            data[i] = (byte) i;
-        }
-
-        for (int i = 0; i < 10; i++) {
-            assertFalse(ch.writeInbound(Unpooled.copiedBuffer(Integer.toHexString(data.length) + "\r\n",
-                    CharsetUtil.US_ASCII)));
-            assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(data)));
-
-            byte[] decodedData = new byte[data.length];
-            HttpContent content = ch.readInbound();
-            assertEquals(32, content.content().readableBytes());
-            content.content().readBytes(decodedData, 0, 32);
-            content.release();
-
-            content = ch.readInbound();
-            assertEquals(32, content.content().readableBytes());
-
-            content.content().readBytes(decodedData, 32, 32);
-
-            assertArrayEquals(data, decodedData);
-            content.release();
-
-            assertFalse(ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII)));
-        }
-
-        // Write the last chunk.
-        ch.writeInbound(Unpooled.copiedBuffer("0\r\n\r\n", CharsetUtil.US_ASCII));
-
-        // Ensure the last chunk was decoded.
-        LastHttpContent content = ch.readInbound();
-        assertFalse(content.content().isReadable());
-        content.release();
-
-        ch.finish();
-        assertNull(ch.readInbound());
-    }
-
     @Test
     public void testClosureWithoutContentLength1() throws Exception {
         EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java
index 17570b758f9..8346112ba24 100644
--- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java
@@ -33,7 +33,7 @@ public class HttpServerCodecTest {
     public void testUnfinishedChunkedHttpRequestIsLastFlag() throws Exception {
 
         int maxChunkSize = 2000;
-        HttpServerCodec httpServerCodec = new HttpServerCodec(1000, 1000, maxChunkSize);
+        HttpServerCodec httpServerCodec = new HttpServerCodec(1000, 1000);
         EmbeddedChannel decoderEmbedder = new EmbeddedChannel(httpServerCodec);
 
         int totalContentLength = maxChunkSize * 5;