ASF Bugzilla – Attachment 33314 Details for
Bug 58593
mod_proxy wrong decision between http and ws
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
mod_proxy_wstunnel fall through http
httpd-2.4.x-proxy_wstunnel_fall_thru_http.patch (text/plain), 2.78 KB, created by
Yann Ylavic
on 2015-11-30 17:41:35 UTC
(
hide
)
Description:
mod_proxy_wstunnel fall through http
Filename:
MIME Type:
Creator:
Yann Ylavic
Created:
2015-11-30 17:41:35 UTC
Size:
2.78 KB
patch
obsolete
>Index: modules/proxy/mod_proxy_wstunnel.c >=================================================================== >--- modules/proxy/mod_proxy_wstunnel.c (revision 1717229) >+++ modules/proxy/mod_proxy_wstunnel.c (working copy) >@@ -31,6 +31,7 @@ static int proxy_wstunnel_canon(request_rec *r, ch > const char *err; > char *scheme; > apr_port_t port, def_port; >+ const char *upgrade; > > /* ap_port_of_scheme() */ > if (strncasecmp(url, "ws:", 3) == 0) { >@@ -47,6 +48,23 @@ static int proxy_wstunnel_canon(request_rec *r, ch > return DECLINED; > } > >+ upgrade = apr_table_get(r->headers_in, "Upgrade"); >+ if (!upgrade || strcasecmp(upgrade, "WebSocket") != 0) { >+ int rc; >+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02900) >+ "No upgrade for %s%s, fall through '%s' scheme", >+ scheme, url, scheme[2] == 's' ? "https:" : "http:"); >+ url = apr_pstrcat(r->pool, scheme[2] == 's' ? "https:" : "http:", url, >+ NULL); >+ rc = proxy_run_canon_handler(r, url); >+ if (rc == DECLINED) { >+ rc = HTTP_UPGRADE_REQUIRED; >+ apr_table_mergen(r->headers_out, "Connection", "Upgrade"); >+ apr_table_setn(r->headers_out, "Upgrade", "WebSocket"); >+ } >+ return rc; >+ } >+ > port = def_port; > ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "canonicalising URL %s", url); > >@@ -315,7 +333,6 @@ static int proxy_wstunnel_handler(request_rec *r, > int status; > char server_portstr[32]; > proxy_conn_rec *backend = NULL; >- const char *upgrade; > char *scheme; > int retry; > conn_rec *c = r->connection; >@@ -335,13 +352,6 @@ static int proxy_wstunnel_handler(request_rec *r, > 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); > >@@ -402,8 +412,13 @@ static int proxy_wstunnel_handler(request_rec *r, > > static void ap_proxy_http_register_hook(apr_pool_t *p) > { >+ /* Canonicalize before mod_proxy_http, so that we can fall through >+ * http(s) scheme when no upgrade is in place. >+ */ >+ static const char * const aszSucc[] = { "mod_proxy_http.c", NULL }; >+ > proxy_hook_scheme_handler(proxy_wstunnel_handler, NULL, NULL, APR_HOOK_FIRST); >- proxy_hook_canon_handler(proxy_wstunnel_canon, NULL, NULL, APR_HOOK_FIRST); >+ proxy_hook_canon_handler(proxy_wstunnel_canon, aszSucc, NULL, APR_HOOK_FIRST); > } > > AP_DECLARE_MODULE(proxy_wstunnel) = {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 58593
: 33314