This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 38d292f Fix HTTP_HOST for HTTP/2 38d292f is described below commit 38d292faeab4d9c9ee8b31394a0b845532ec6ad3 Author: Mark Thomas <ma...@apache.org> AuthorDate: Sat Feb 8 08:45:46 2020 +0000 Fix HTTP_HOST for HTTP/2 --- java/org/apache/catalina/valves/rewrite/ResolverImpl.java | 13 +++++-------- webapps/docs/changelog.xml | 6 ++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/java/org/apache/catalina/valves/rewrite/ResolverImpl.java b/java/org/apache/catalina/valves/rewrite/ResolverImpl.java index 8d95293..f880ca5 100644 --- a/java/org/apache/catalina/valves/rewrite/ResolverImpl.java +++ b/java/org/apache/catalina/valves/rewrite/ResolverImpl.java @@ -49,14 +49,11 @@ public class ResolverImpl extends Resolver { } else if (key.equals("HTTP_FORWARDED")) { return request.getHeader("forwarded"); } else if (key.equals("HTTP_HOST")) { - String host = request.getHeader("host"); - if (host != null) { - int index = host.indexOf(':'); - if (index != -1) { - host = host.substring(0, index); - } - } - return host; + // Don't look directly at the host header to handle: + // - Host name in HTTP/1.1 request line + // - HTTP/0.9 & HTTP/1.0 requests + // - HTTP/2 :authority pseudo header + return request.getServerName(); } else if (key.equals("HTTP_PROXY_CONNECTION")) { return request.getHeader("proxy-connection"); } else if (key.equals("HTTP_ACCEPT")) { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 9ef9ead..d45f457 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -50,6 +50,12 @@ <fix> Store config compatibility with HostWebXmlCacheCleaner listener. (remm) </fix> + <fix> + Modify the <code>RewriteValve</code> to use + <code>ServletRequest.getServerName()</code> to populate the + <code>HTTP_HOST</code> variable rather than extracting it from the + <code>Host</code> header as this allows HTTP/2 to be supported. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org