]> granicus.if.org Git - apache/commitdiff
Fix a problem where we are doing a case insensitive
authorJim Jagielski <jim@apache.org>
Mon, 31 Oct 2005 16:31:29 +0000 (16:31 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 31 Oct 2005 16:31:29 +0000 (16:31 +0000)
match between the worker and the URL. Instead, only
the scheme and hostname are insensitive, the rest
should be case sensitive.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@329849 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index 721bf31cd27d7a7103f92f67a115647210acff4a..edabbbbc5de6cb35bf8e1fc098305b9a9ef98627 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) mod_proxy_balancer: When finding best worker, use case insensitive
+     match for scheme and host, but case sensitive for the rest of
+     the path. [Jim Jagielski]
+
   *) Asynchronous write completion for the Event MPM.  [Brian Pane]
 
   *) Added an End-Of-Request bucket type.  The logging of a request and
index b78d019708b38af06be1b9e11c9cea94b7970f4f..3dc2e1d16c7cc2bf951eaff07a336653c2414b58 100644 (file)
@@ -1216,6 +1216,7 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
     int max_match = 0;
     int url_length;
     int worker_name_length;
+    int sh_length;
     const char *c;
     int i;
 
@@ -1224,6 +1225,18 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
        return NULL;
 
     url_length = strlen(url);
+
+    /*
+     * We need to find the start of the path and
+     * therefore we know the length of the scheme://hostname/
+     * part.
+     */
+    c = ap_strchr_c(c+3, '/');
+    if (c)
+        sh_length = c - url;
+    else
+        sh_length = url_length;
+    
     worker = (proxy_worker *)conf->workers->elts;
 
     /*
@@ -1231,9 +1244,22 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
      * fits best to the URL.
      */
     for (i = 0; i < conf->workers->nelts; i++) {
-        if ( ((worker_name_length = strlen(worker->name)) <= url_length)
+        int prefix;
+        int bypass;
+        worker_name_length = strlen(worker->name);
+        if (worker_name_length <= sh_length) {
+            prefix = worker_name_length;
+            bypass = 1;
+        } else {
+            prefix = sh_length;
+            bypass = 0;
+        }
+        if ( (worker_name_length <= url_length)
            && (worker_name_length > max_match)
-           && (strncasecmp(url, worker->name, worker_name_length) == 0) ) {
+           && (strncasecmp(url, worker->name, prefix) == 0)
+           && (bypass || (strncmp(url + prefix, worker->name + prefix,
+                          worker_name_length - prefix) == 0)) )
+        {
             max_worker = worker;
             max_match = worker_name_length;
         }