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 513d2aa415..22271d81d0 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 @@ -477,7 +477,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 f346de91c9..017dbd5ff9 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 @@ -368,6 +368,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 = ch.readInbound(); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.RESET_CONTENT)); + + LastHttpContent lastContent = 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());