diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java index b0c544be88..6ba0713315 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java @@ -318,7 +318,7 @@ public final class HttpConversionUtil { // HTTP/1.1 status line. final HttpResponse msg = new DefaultHttpResponse(HttpVersion.HTTP_1_1, status, validateHttpHeaders); try { - addHttp2ToHttpHeaders(streamId, http2Headers, msg.headers(), msg.protocolVersion(), false, true); + addHttp2ToHttpHeaders(streamId, http2Headers, msg.headers(), msg.protocolVersion(), false, false); } catch (final Http2Exception e) { throw e; } catch (final Throwable t) { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpConversionUtilTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpConversionUtilTest.java index 4ab4ea63b8..cb4bc66ad9 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpConversionUtilTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpConversionUtilTest.java @@ -189,4 +189,22 @@ public class HttpConversionUtilTest { assertFalse(outHeaders.contains(TRANSFER_ENCODING)); assertFalse(outHeaders.contains(UPGRADE)); } + + @Test + public void http2ToHttpHeaderTest() throws Exception { + Http2Headers http2Headers = new DefaultHttp2Headers(); + http2Headers.status("200"); + http2Headers.path("/meow"); // HTTP/2 Header response should not contain 'path' in response. + http2Headers.set("cat", "meow"); + + HttpHeaders httpHeaders = new DefaultHttpHeaders(); + HttpConversionUtil.addHttp2ToHttpHeaders(3, http2Headers, httpHeaders, HttpVersion.HTTP_1_1, false, true); + assertFalse(httpHeaders.contains(HttpConversionUtil.ExtensionHeaderNames.PATH.text())); + assertEquals("meow", httpHeaders.get("cat")); + + httpHeaders.clear(); + HttpConversionUtil.addHttp2ToHttpHeaders(3, http2Headers, httpHeaders, HttpVersion.HTTP_1_1, false, false); + assertTrue(httpHeaders.contains(HttpConversionUtil.ExtensionHeaderNames.PATH.text())); + assertEquals("meow", httpHeaders.get("cat")); + } }