httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r160675 - httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
Date Sat, 09 Apr 2005 10:12:02 GMT
Author: mturk
Date: Sat Apr  9 03:12:01 2005
New Revision: 160675

URL: http://svn.apache.org/viewcvs?view=rev&rev=160675
Log:
Add canon_handler for load balancer so that we have
query string passed to remote.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?view=diff&r1=160674&r2=160675
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Sat Apr  9 03:12:01 2005
@@ -24,6 +24,57 @@
 
 module AP_MODULE_DECLARE_DATA proxy_balancer_module;
 
+static int proxy_balancer_canon(request_rec *r, char *url)
+{
+    char *host, *path, *search;
+    const char *err;
+    const char *scheme;
+    apr_port_t port = 0;
+
+    if (strncasecmp(url, "balancer:", 9) == 0) {
+        url += 9;
+        scheme = "balancer";
+    }    
+    else {
+        return DECLINED;
+    }
+
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+             "proxy: BALANCER: canonicalising URL %s", url);
+
+    /* do syntatic check.
+     * We break the URL into host, port, path, search
+     */
+    err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
+    if (err) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                      "error parsing URL %s: %s",
+                      url, err);
+        return HTTP_BAD_REQUEST;
+    }
+    /* now parse path/search args, according to rfc1738 */
+    /* N.B. if this isn't a true proxy request, then the URL _path_
+     * has already been decoded.  True proxy requests have r->uri
+     * == r->unparsed_uri, and no others have that property.
+     */
+    if (r->uri == r->unparsed_uri) {
+        search = strchr(url, '?');
+        if (search != NULL)
+            *(search++) = '\0';
+    }
+    else
+        search = r->args;
+
+    /* process path */
+    path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0, r->proxyreq);
+    if (path == NULL)
+        return HTTP_BAD_REQUEST;
+
+    r->filename = apr_pstrcat(r->pool, "proxy:", scheme, "://", host,
+            "/", path, (search) ? "?" : "", (search) ? search : "", NULL);
+    return OK;
+}
+
 static int init_balancer_members(proxy_server_conf *conf, server_rec *s,
                                  proxy_balancer *balancer)
 {
@@ -824,6 +875,7 @@
     ap_hook_child_init(child_init, aszPred, NULL, APR_HOOK_MIDDLE); 
     proxy_hook_pre_request(proxy_balancer_pre_request, NULL, NULL, APR_HOOK_FIRST);    
     proxy_hook_post_request(proxy_balancer_post_request, NULL, NULL, APR_HOOK_FIRST);   

+    proxy_hook_canon_handler(proxy_balancer_canon, NULL, NULL, APR_HOOK_FIRST);
 }
 
 module AP_MODULE_DECLARE_DATA proxy_balancer_module = {



Mime
View raw message