From: Jim Jagielski
Date: Mon, 18 Sep 2017 13:05:46 +0000 (+0000)
Subject: Merge r1801594 from trunk:
X-Git-Tag: 2.4.28~26
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18457241ad140fd54b01a1abdbbf62a3a786a763;p=apache
Merge r1801594 from trunk:
Add logic to read the Upgrade header and use it in the response.
Use we you are proxying to a server that has multiple upgrade on the same IP/Port.
PR 61142
Submitted by: jfclere
Reviewed by: jfclere, jim, covener
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1808698 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/CHANGES b/CHANGES
index 6fa4c307e9..b2b6bada88 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes with Apache 2.4.28
+ *) mod_proxy_wstunnel: Allow upgrade to any protocol dynamically.
+ PR 61142.
+
*) mod_watchdog/mod_proxy_hcheck: Time intervals can now be spefified
down to the millisecond. Supports 'mi' (minute), 'ms' (millisecond),
's' (second) and 'hr' (hour!) time suffixes. [Jim Jagielski]
diff --git a/STATUS b/STATUS
index 66357e73e1..47ff449fc7 100644
--- a/STATUS
+++ b/STATUS
@@ -115,10 +115,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- *) mod_proxy_wstunnel fix PR 61142
- 2.4.x patch: svn merge -c 1801594 ^/httpd/httpd/trunk .
- +1: jfclere, jim, covener
- ylavic: CHANGES-log please?
PATCHES PROPOSED TO BACKPORT FROM TRUNK:
diff --git a/docs/manual/mod/mod_proxy_wstunnel.xml b/docs/manual/mod/mod_proxy_wstunnel.xml
index 639131ba2d..4d46e5bf8b 100644
--- a/docs/manual/mod/mod_proxy_wstunnel.xml
+++ b/docs/manual/mod/mod_proxy_wstunnel.xml
@@ -55,7 +55,9 @@ ProxyPass "/wss2/" "wss://echo.websocket.org/"
In fact the module can be used to upgrade to other protocols, you can set the upgrade
parameter in the ProxyPass
directive to allow the module to accept other protocol.
-NONE means you bypass the check for the header but still upgrade to WebSocket.
+NONE means you bypass the check for the header but still upgrade to WebSocket.
+ANY means that Upgrade
will read in the request headers and use
+in the response Upgrade
mod_proxy
diff --git a/modules/proxy/mod_proxy_wstunnel.c b/modules/proxy/mod_proxy_wstunnel.c
index b0f3bcc661..c9949e25a2 100644
--- a/modules/proxy/mod_proxy_wstunnel.c
+++ b/modules/proxy/mod_proxy_wstunnel.c
@@ -131,6 +131,10 @@ static int proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
if (ap_cstr_casecmp(upgrade_method, "NONE") == 0) {
buf = apr_pstrdup(p, "Upgrade: WebSocket" CRLF "Connection: Upgrade" CRLF CRLF);
+ } else if (ap_cstr_casecmp(upgrade_method, "ANY") == 0) {
+ const char *upgrade;
+ upgrade = apr_table_get(r->headers_in, "Upgrade");
+ buf = apr_pstrcat(p, "Upgrade: ", upgrade, CRLF "Connection: Upgrade" CRLF CRLF, NULL);
} else {
buf = apr_pstrcat(p, "Upgrade: ", upgrade_method, CRLF "Connection: Upgrade" CRLF CRLF, NULL);
}
@@ -302,7 +306,8 @@ static int proxy_wstunnel_handler(request_rec *r, proxy_worker *worker,
if (ap_cstr_casecmp(upgrade_method, "NONE") != 0) {
const char *upgrade;
upgrade = apr_table_get(r->headers_in, "Upgrade");
- if (!upgrade || ap_cstr_casecmp(upgrade, upgrade_method) != 0) {
+ if (!upgrade || (ap_cstr_casecmp(upgrade, upgrade_method) != 0 &&
+ ap_cstr_casecmp(upgrade_method, "ANY") !=0)) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02900)
"declining URL %s (not %s, Upgrade: header is %s)",
url, upgrade_method, upgrade ? upgrade : "missing");