From 500c7edbbd72bac8fe672ab1d72624d3be3155f3 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Sun, 19 Apr 2015 18:06:05 +0000 Subject: [PATCH] Merge r1674632 from trunk: mod_proxy_wstunnel: Bypass the handler while the connection is not upgraded to WebSocket, so that other modules can possibly take over the leading HTTP requests. Submitted by: ylavic Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1674661 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ STATUS | 6 ------ modules/proxy/mod_proxy_wstunnel.c | 8 ++++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index c76eb5e2bb..17410ffb3e 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,10 @@ Changes with Apache 2.4.13 calls r:wsupgrade() can cause a child process crash. [Edward Lu ] + *) mod_proxy_wstunnel: Bypass the handler while the connection is not + upgraded to WebSocket, so that other modules can possibly take over + the leading HTTP requests. [Yann Ylavic] + *) mod_http: Fix incorrect If-Match handling. PR 57358 [Kunihiko Sakamoto ] diff --git a/STATUS b/STATUS index 716790f6f5..09e013b038 100644 --- a/STATUS +++ b/STATUS @@ -105,12 +105,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_proxy_wstunnel: Bypass the handler while the connection is not - upgraded to WebSocket, so that other modules can possibly take over - the leading HTTP requests. - trunk patch: http://svn.apache.org/r1674632 - 2.4.x patch: trunk works (modulo CHANGES, docs/log-message-tags) - +1: ylavic, covener, jim PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/proxy/mod_proxy_wstunnel.c b/modules/proxy/mod_proxy_wstunnel.c index fb72041bdf..7c283b8e02 100644 --- a/modules/proxy/mod_proxy_wstunnel.c +++ b/modules/proxy/mod_proxy_wstunnel.c @@ -315,6 +315,7 @@ static int proxy_wstunnel_handler(request_rec *r, proxy_worker *worker, int status; char server_portstr[32]; proxy_conn_rec *backend = NULL; + const char *upgrade; char *scheme; int retry; conn_rec *c = r->connection; @@ -334,6 +335,13 @@ static int proxy_wstunnel_handler(request_rec *r, proxy_worker *worker, return DECLINED; } + upgrade = apr_table_get(r->headers_in, "Upgrade"); + if (!upgrade || strcasecmp(upgrade, "WebSocket") != 0) { + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02900) + "declining URL %s (not WebSocket)", url); + return DECLINED; + } + uri = apr_palloc(p, sizeof(*uri)); ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02451) "serving URL %s", url); -- 2.40.0