httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1602523 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c proxy_util.c
Date Fri, 13 Jun 2014 21:10:52 GMT
Author: jim
Date: Fri Jun 13 21:10:51 2014
New Revision: 1602523

URL: http://svn.apache.org/r1602523
Log:
Allow for "magic" scheme "auto" which makes the scheme of
the backend worker match whatever the scheme of the
incoming request was...

For example:

   ProxyPass / auto://foo.example.com/

If the incoming request is http:.../lala then
the resultant will be http://foo.example.com/lala

If it's wws:.../lolo then we'd send
wws://foo.example.com/lolo

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1602523&r1=1602522&r2=1602523&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Fri Jun 13 21:10:51 2014
@@ -1045,6 +1045,11 @@ static int proxy_handler(request_rec *r)
     }
 
     scheme = apr_pstrndup(r->pool, uri, p - uri);
+
+    if (strcmp(scheme, "auto") == 0) {
+        apr_table_set(r->notes, "auto", uri);
+        uri = apr_pstrcat(r->pool, ap_http_scheme(r), p, NULL);
+    }
     /* Check URI's destination host against NoProxy hosts */
     /* Bypass ProxyRemote server lookup if configured as NoProxy */
     for (direct_connect = i = 0; i < conf->dirconn->nelts &&
@@ -1151,8 +1156,8 @@ static int proxy_handler(request_rec *r)
 
         /* handle the scheme */
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01143)
-                      "Running scheme %s handler (attempt %d)",
-                      scheme, attempts);
+                      "Running scheme %s handler for %s (attempt %d)",
+                      scheme, url, attempts);
         AP_PROXY_RUN(r, worker, conf, url, attempts);
         access_status = proxy_run_scheme_handler(r, worker, conf,
                                                  url, NULL, 0);
@@ -1479,7 +1484,7 @@ static const char *
 
 static char *de_socketfy(apr_pool_t *p, char *url)
 {
-    char *ptr;
+    char *ptr, *ret = url;
     /*
      * We could be passed a URL during the config stage that contains
      * the UDS path... ignore it
@@ -1487,7 +1492,7 @@ static char *de_socketfy(apr_pool_t *p, 
     if (!strncasecmp(url, "unix:", 5) &&
         ((ptr = ap_strchr(url, '|')) != NULL)) {
         /* move past the 'unix:...|' UDS path info */
-        char *ret, *c;
+        char *c;
 
         ret = ptr + 1;
         /* special case: "unix:....|scheme:" is OK, expand
@@ -1498,13 +1503,10 @@ static char *de_socketfy(apr_pool_t *p, 
             return NULL;
         }
         if (c[1] == '\0') {
-            return apr_pstrcat(p, ret, "//localhost", NULL);
-        }
-        else {
-            return ret;
+            ret = apr_pstrcat(p, ret, "//localhost", NULL);
         }
     }
-    return url;
+    return ret;
 }
 
 static const char *

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1602523&r1=1602522&r2=1602523&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Fri Jun 13 21:10:51 2014
@@ -1907,7 +1907,11 @@ PROXY_DECLARE(int) ap_proxy_pre_request(
 
     access_status = proxy_run_pre_request(worker, balancer, r, conf, url);
     if (access_status == DECLINED && *balancer == NULL) {
-        *worker = ap_proxy_get_worker(r->pool, NULL, conf, *url);
+        const char *murl;
+        if ((murl = apr_table_get(r->notes, "auto")) == NULL) {
+            murl = *url;
+        }
+        *worker = ap_proxy_get_worker(r->pool, NULL, conf, murl);
         if (*worker) {
             ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
                           "%s: found worker %s for %s",



Mime
View raw message