Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 56726 invoked from network); 1 Nov 2005 13:06:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Nov 2005 13:06:10 -0000 Received: (qmail 67303 invoked by uid 500); 1 Nov 2005 13:06:05 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 67246 invoked by uid 500); 1 Nov 2005 13:06:05 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 67235 invoked by uid 99); 1 Nov 2005 13:06:05 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2005 05:06:05 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [209.133.192.6] (HELO devsys.jaguNET.com) (209.133.192.6) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2005 05:06:00 -0800 Received: (from jim@localhost) by devsys.jaguNET.com (8.11.7a/jag-2.6) id jA1D5hB05835 for dev@httpd.apache.org; Tue, 1 Nov 2005 08:05:43 -0500 (EST) From: Jim Jagielski Message-Id: <200511011305.jA1D5hB05835@devsys.jaguNET.com> Subject: Re: svn commit: r329849 - in /httpd/httpd/trunk: CHANGES modules/proxy/proxy_util.c To: dev@httpd.apache.org Date: Tue, 1 Nov 2005 08:05:40 -0500 (EST) Reply-To: jim@jaguNET.com In-Reply-To: from "Ruediger Pluem" at Oct 31, 2005 11:29:48 PM X-Mailer: ELM [version 2.5 PL5] MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I wanted to avoid making string copies when possible. Plus, we don't want to lowercase the URL, since that means /Foo/bar would be the same as /FOO/Bar, which is wrong :) Ruediger Pluem wrote: > > > > On 10/31/2005 05:31 PM, jim@apache.org wrote: > > Author: jim > > Date: Mon Oct 31 08:31:29 2005 > > New Revision: 329849 > > > > URL: http://svn.apache.org/viewcvs?rev=329849&view=rev > > Log: > > Fix a problem where we are doing a case insensitive > > match between the worker and the URL. Instead, only > > the scheme and hostname are insensitive, the rest > > should be case sensitive. > > > > Modified: > > httpd/httpd/trunk/CHANGES > > httpd/httpd/trunk/modules/proxy/proxy_util.c > > > Thanks for looking into this. I think this is also related to PR36906. > > Given the fact that the hostname and the schema already get lowercased by > ap_proxy_add_worker, wouldn't it be faster and clearer to do something like > the following (honest question, I do not know the answer and the best code should > go in): > > > PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p, > proxy_server_conf *conf, > const char *url) > { > proxy_worker *worker; > proxy_worker *max_worker = NULL; > int max_match = 0; > int url_length; > int worker_name_length; > const char *c; > int i; > char *url_copy; > > c = ap_strchr_c(url, ':'); > if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') > return NULL; > > url_copy = apr_pstrdup(p, url); > url_length = strlen(url_copy); > > /* > * We need to find the start of the path and > * and lowercase all characters before. > */ > c = ap_strchr_c(c+3, '/'); > if (c) { > *c = '\0'; > ap_str_tolower(url_copy); > *c = '/'; > } > else { > ap_str_tolower(url_copy); > } > > worker = (proxy_worker *)conf->workers->elts; > > /* > * Do a "longest match" on the worker name to find the worker that > * fits best to the URL. > */ > for (i = 0; i < conf->workers->nelts; i++) { > if ( ((worker_name_length = strlen(worker->name)) <= url_length) > && (worker_name_length > max_match) > && (strncmp(url_copy, worker->name, worker_name_length) == 0)) { > max_worker = worker; > max_match = worker_name_length; > } > worker++; > } > return max_worker; > } > > Regards > > RĂ¼diger > -- ======================================================================= Jim Jagielski [|] jim@jaguNET.com [|] http://www.jaguNET.com/ "If you can dodge a wrench, you can dodge a ball."