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 48cbfbb151..1043e73596 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 @@ -479,7 +479,7 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder { } switch (code) { - case 204: case 205: case 304: + case 204: case 304: return true; } } 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 5db91d6bc8..ec4bf70949 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 @@ -332,6 +332,28 @@ public class HttpResponseDecoderTest { assertThat(ch.readInbound(), is(nullValue())); } + @Test + public void testResetContentResponseWithTransferEncoding() { + EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder()); + assertTrue(ch.writeInbound(Unpooled.copiedBuffer( + "HTTP/1.1 205 Reset Content\r\n" + + "Transfer-Encoding: chunked\r\n" + + "\r\n" + + "0\r\n" + + "\r\n", + CharsetUtil.US_ASCII))); + + HttpResponse res = (HttpResponse) ch.readInbound(); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), is(HttpResponseStatus.RESET_CONTENT)); + + LastHttpContent lastContent = (LastHttpContent) ch.readInbound(); + assertThat(lastContent.content().isReadable(), is(false)); + lastContent.release(); + + assertThat(ch.finish(), is(false)); + } + @Test public void testLastResponseWithTrailingHeader() { EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());