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 3231c50a92..c88a1a59bb 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 @@ -68,7 +68,6 @@ public final class HttpConversionUtil { add(HttpHeaderNames.HOST); add(HttpHeaderNames.UPGRADE); add(ExtensionHeaderNames.STREAM_ID.text()); - add(ExtensionHeaderNames.AUTHORITY.text()); add(ExtensionHeaderNames.SCHEME.text()); add(ExtensionHeaderNames.PATH.text()); } @@ -112,14 +111,6 @@ public final class HttpConversionUtil { * {@code "x-http2-stream-id"} */ STREAM_ID("x-http2-stream-id"), - - /** - * HTTP extension header which will identify the authority pseudo header from the HTTP/2 event(s) responsible - * for generating a {@code HttpObject} - *

- * {@code "x-http2-authority"} - */ - AUTHORITY("x-http2-authority"), /** * HTTP extension header which will identify the scheme pseudo header from the HTTP/2 event(s) responsible for * generating a {@code HttpObject} @@ -311,11 +302,8 @@ public final class HttpConversionUtil { if (!isOriginForm(requestTargetUri) && !isAsteriskForm(requestTargetUri)) { // Attempt to take from HOST header before taking from the request-line String host = inHeaders.getAsString(HttpHeaderNames.HOST); - if (host == null || host.isEmpty()) { - setHttp2Authority(inHeaders, requestTargetUri.getAuthority(), out); - } else { - setHttp2Authority(inHeaders, host, out); - } + setHttp2Authority(inHeaders, + (host == null || host.isEmpty()) ? requestTargetUri.getAuthority() : host, out); } } else if (in instanceof HttpResponse) { HttpResponse response = (HttpResponse) in; @@ -381,13 +369,6 @@ public final class HttpConversionUtil { } else { throw new IllegalArgumentException("autority: " + autority); } - } else { - // Consume the Authority extension header if present - CharSequence cValue = in.get(ExtensionHeaderNames.AUTHORITY.text()); - if (cValue != null) { - // Assume this is sanitized of all "userinfo" - out.authority(AsciiString.of(cValue)); - } } } @@ -428,7 +409,7 @@ public final class HttpConversionUtil { RESPONSE_HEADER_TRANSLATIONS = new HashMap(); static { RESPONSE_HEADER_TRANSLATIONS.put(Http2Headers.PseudoHeaderName.AUTHORITY.value(), - ExtensionHeaderNames.AUTHORITY.text()); + HttpHeaderNames.HOST); RESPONSE_HEADER_TRANSLATIONS.put(Http2Headers.PseudoHeaderName.SCHEME.value(), ExtensionHeaderNames.SCHEME.text()); REQUEST_HEADER_TRANSLATIONS.putAll(RESPONSE_HEADER_TRANSLATIONS); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java index 9d10e0d3bc..5640f8a4d8 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java @@ -125,7 +125,6 @@ public class HttpToHttp2ConnectionHandlerTest { final HttpHeaders httpHeaders = request.headers(); httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5); httpHeaders.set(HttpHeaderNames.HOST, "my-user_name@www.example.org:5555"); - httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.AUTHORITY.text(), "www.example.org:5555"); httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "http"); httpHeaders.add("foo", "goo"); httpHeaders.add("foo", "goo2"); @@ -182,25 +181,6 @@ public class HttpToHttp2ConnectionHandlerTest { httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5); httpHeaders.set(HttpHeaderNames.HOST, "foouser@www.example.org:5555"); httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.PATH.text(), "ignored_path"); - httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.AUTHORITY.text(), "ignored_authority"); - httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "https"); - final Http2Headers http2Headers = - new DefaultHttp2Headers().method(new AsciiString("GET")) - .path(new AsciiString("/pub/WWW/TheProject.html")) - .authority(new AsciiString("www.example.org:5555")).scheme(new AsciiString("https")); - - ChannelPromise writePromise = newPromise(); - verifyHeadersOnly(http2Headers, writePromise, clientChannel.writeAndFlush(request, writePromise)); - } - - @Test - public void testAbsoluteFormRequestTargetHandledFromHeadersNoHost() throws Exception { - bootstrapEnv(2, 1, 0); - final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/pub/WWW/TheProject.html"); - final HttpHeaders httpHeaders = request.headers(); - httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5); - httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.PATH.text(), "ignored_path"); - httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.AUTHORITY.text(), "www.example.org:5555"); httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "https"); final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("GET")) diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java index da97cfdfcc..4aa9f27db8 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java @@ -134,7 +134,7 @@ public class InboundHttp2ToHttpAdapterTest { try { HttpHeaders httpHeaders = request.headers(); httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "https"); - httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.AUTHORITY.text(), "example.org"); + httpHeaders.set(HttpHeaderNames.HOST, "example.org"); httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 3); httpHeaders.setInt(HttpHeaderNames.CONTENT_LENGTH, 0); final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("GET")). @@ -480,7 +480,7 @@ public class InboundHttp2ToHttpAdapterTest { httpHeaders.setInt(HttpHeaderNames.CONTENT_LENGTH, text.length()); HttpHeaders httpHeaders2 = response2.headers(); httpHeaders2.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "https"); - httpHeaders2.set(HttpConversionUtil.ExtensionHeaderNames.AUTHORITY.text(), "example.org"); + httpHeaders2.set(HttpHeaderNames.HOST, "example.org"); httpHeaders2.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5); httpHeaders2.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_PROMISE_ID.text(), 3); httpHeaders2.setInt(HttpHeaderNames.CONTENT_LENGTH, text2.length());