From 6667b590c4fceba3f9712c564f97c9952ec332f6 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 29 Oct 2019 19:48:43 +0100 Subject: [PATCH] =?UTF-8?q?HttpClientCodec=20need=20to=20keep=20request=20?= =?UTF-8?q?/=20response=20pairs=20in=20sync=20all=20the=E2=80=A6=20(#9721)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Motivation: At the moment we miss to poll the method queue when we see an Informational response code. This can lead to out-of-sync of request / response pairs when later try to compare these. Modifications: Always poll the queue correctly Result: Always compare the correct request / response pairs --- .../handler/codec/http/HttpClientCodec.java | 11 +++-- .../codec/http/HttpClientCodecTest.java | 43 +++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) 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 fb0e437d4b..990faf78da 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 @@ -222,6 +222,13 @@ public final class HttpClientCodec extends CombinedChannelDuplexHandler= 100 && statusCode < 200) { // An informational response should be excluded from paired comparison. @@ -229,10 +236,6 @@ public final class HttpClientCodec extends CombinedChannelDuplexHandlerinstanceOf(LastHttpContent.class)); + content.release(); + + assertTrue(ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"))); + buffer = ch.readOutbound(); + buffer.release(); + assertNull(ch.readOutbound()); + assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(data2))); + + res = ch.readInbound(); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); + content = ch.readInbound(); + // HTTP 200 has content. + assertThat(content.content().readableBytes(), is(8)); + assertThat(content, CoreMatchers.instanceOf(LastHttpContent.class)); + content.release(); + + assertThat(ch.finish(), is(false)); + } + @Test public void testMultipleResponses() { String response = "HTTP/1.1 200 OK\r\n" +