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 2019/09/19 13:46:55 UTC
[tomcat] branch master updated: Fix
https://bz.apache.org/bugzilla/show_bug.cgi?id=63753 WS host header
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 6bddb90 Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63753 WS host header
6bddb90 is described below
commit 6bddb9012d61e243e0136ee9187c71236c382e0a
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 19 14:46:09 2019 +0100
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63753 WS host header
Ensure that the Host header in a Web Socket HTTP upgrade request only
contains a port if a non-default port is being used.
---
java/org/apache/tomcat/websocket/WsWebSocketContainer.java | 7 ++++---
webapps/docs/changelog.xml | 9 +++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index 1754538..4ea31fc 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -265,7 +265,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce
}
// Create the initial HTTP request to open the WebSocket connection
- Map<String, List<String>> reqHeaders = createRequestHeaders(host, port,
+ Map<String, List<String>> reqHeaders = createRequestHeaders(host, port, secure,
clientEndpointConfiguration);
clientEndpointConfiguration.getConfigurator().beforeRequest(reqHeaders);
if (Constants.DEFAULT_ORIGIN_HEADER_VALUE != null
@@ -631,7 +631,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce
}
private static Map<String, List<String>> createRequestHeaders(String host, int port,
- ClientEndpointConfig clientEndpointConfiguration) {
+ boolean secure, ClientEndpointConfig clientEndpointConfiguration) {
Map<String, List<String>> headers = new HashMap<>();
List<Extension> extensions = clientEndpointConfiguration.getExtensions();
@@ -646,7 +646,8 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce
// Host header
List<String> hostValues = new ArrayList<>(1);
- if (port == -1) {
+ if (port == 80 && !secure || port == 443 && secure) {
+ // Default ports. Do not include port in host header
hostValues.add(host);
} else {
hostValues.add(host + ':' + port);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 58a0809..24bf3c6 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -54,6 +54,15 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Web Socket">
+ <changelog>
+ <fix>
+ <bug>63753</bug>: Ensure that the <code>Host</code> header in a Web
+ Socket HTTP upgrade request only contains a port if a non-default port
+ is being used. (markt)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Web Applications">
<changelog>
<docs>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org