diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseConformance.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseConformance.java index 61e9dc3bb4..a05a6c5fcb 100644 --- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseConformance.java +++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseConformance.java @@ -65,6 +65,7 @@ public H2ResponseConformance() { this( HttpHeaders.CONNECTION, HttpHeaders.KEEP_ALIVE, + HttpHeaders.PROXY_CONNECTION, HttpHeaders.TRANSFER_ENCODING, HttpHeaders.UPGRADE); } diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/protocol/TestH2Interceptors.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/protocol/TestH2Interceptors.java index 38410c7871..ed3e9365fe 100644 --- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/protocol/TestH2Interceptors.java +++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/protocol/TestH2Interceptors.java @@ -258,4 +258,20 @@ void testH2ResponseConformanceUpgradeHeader() { "Header 'upgrade: example/1, foo/2' is illegal for HTTP/2 messages"); } + @Test + void testProxyConnectionRejected() { + final BasicHttpResponse response = new BasicHttpResponse(200, "OK"); + response.addHeader(HttpHeaders.PROXY_CONNECTION, "keep-alive"); + + Assertions.assertThrows( + ProtocolException.class, + () -> H2ResponseConformance.INSTANCE.process(response, null, HttpCoreContext.create())); + } + + @Test + void testNoIllegalHeaders() throws Exception { + final BasicHttpResponse response = new BasicHttpResponse(200, "OK"); + H2ResponseConformance.INSTANCE.process(response, null, HttpCoreContext.create()); + } + }