You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/02/08 08:52:21 UTC
[tomcat] branch master updated: Fix HTTP_HOST for HTTP/2
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 74cbdf6 Fix HTTP_HOST for HTTP/2
74cbdf6 is described below
commit 74cbdf61b5f45904d47766ad4bf3465f39cae4a7
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 db97221..a71d64c 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 10e5a53..1dbaf97 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org