From 76f7cbf48586a15d20295a3c52ea3493bd94e036 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Sun, 19 Apr 2015 15:51:03 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1674632 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ docs/log-message-tags/next-number | 2 +- modules/proxy/mod_proxy_wstunnel.c | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index a94d77ca3e..20715c13ab 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) 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_proxy_scgi: ProxySCGIInternalRedirect now allows an alternate response header to be used by the application, for when the application or framework is unable to return Location in the internal-redirect diff --git a/docs/log-message-tags/next-number b/docs/log-message-tags/next-number index d77de05557..c914c6a5d9 100644 --- a/docs/log-message-tags/next-number +++ b/docs/log-message-tags/next-number @@ -1 +1 @@ -2900 +2901 diff --git a/modules/proxy/mod_proxy_wstunnel.c b/modules/proxy/mod_proxy_wstunnel.c index 11bc02d99b..f0816b261c 100644 --- a/modules/proxy/mod_proxy_wstunnel.c +++ b/modules/proxy/mod_proxy_wstunnel.c @@ -466,6 +466,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; @@ -485,6 +486,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