From 9024f462376f59e8a1bdca8f31db68ed397b1e99 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sat, 12 Oct 2024 15:22:39 +0200 Subject: [PATCH] Bug fix: allow `Host` headers in HTTP/2 request messages --- .../apache/hc/core5/http2/protocol/H2RequestConformance.java | 1 - .../apache/hc/core5/http2/protocol/TestH2Interceptors.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConformance.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConformance.java index b7634a86c..354c36058 100644 --- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConformance.java +++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConformance.java @@ -66,7 +66,6 @@ public H2RequestConformance() { HttpHeaders.KEEP_ALIVE, HttpHeaders.PROXY_CONNECTION, HttpHeaders.TRANSFER_ENCODING, - HttpHeaders.HOST, HttpHeaders.UPGRADE, HttpHeaders.TE); } 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 ef2e84aaa..38410c787 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 @@ -194,8 +194,8 @@ void testH2RequestConformanceHostHeader() { request.addHeader("Host", "host"); final H2RequestConformance interceptor = new H2RequestConformance(); - Assertions.assertThrows(HttpException.class, () -> interceptor.process(request, null, context), - "Header 'Host: host' is illegal for HTTP/2 messages"); + Assertions.assertDoesNotThrow(() -> interceptor.process(request, null, context), + "Header 'Host: host' is permissible for HTTP/2 messages"); } @Test