ASF Bugzilla – Attachment 18889 Details for
Bug 40169
CacheEnable not caching Forward proxy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fixes some issues in 'CacheEnable' and 'CacheDisable' matching and extends a bit the functionality.
httpd-2.2.3-cachematch.patch (text/plain), 5.30 KB, created by
Peter Grandi
on 2006-09-20 00:09:15 UTC
(
hide
)
Description:
Fixes some issues in 'CacheEnable' and 'CacheDisable' matching and extends a bit the functionality.
Filename:
MIME Type:
Creator:
Peter Grandi
Created:
2006-09-20 00:09:15 UTC
Size:
5.30 KB
patch
obsolete
>--- httpd-2.2.3-orig/modules/cache/cache_util.c 2006-07-12 04:38:44.000000000 +0100 >+++ httpd-2.2.3/modules/cache/cache_util.c 2006-09-20 00:41:43.013193180 +0100 >@@ -26,49 +26,83 @@ > > /* Determine if "url" matches the hostname, scheme and port and path > * in "filter". All but the path comparisons are case-insensitive. >+ * Note: the 's' parameters is not used currently, but needed for >+ * logging during debugging. > */ >-static int uri_meets_conditions(apr_uri_t filter, int pathlen, apr_uri_t url) >+static int uri_meets_conditions(const server_rec *const s, >+ const apr_uri_t filter,const int pathlen,const apr_uri_t url) > { >- /* Compare the hostnames */ >- if(filter.hostname) { >- if (!url.hostname) { >- return 0; >- } >- else if (strcasecmp(filter.hostname, url.hostname)) { >- return 0; >- } >- } >+ (void) s; > >- /* Compare the schemes */ >- if(filter.scheme) { >- if (!url.scheme) { >- return 0; >- } >- else if (strcasecmp(filter.scheme, url.scheme)) { >- return 0; >- } >- } >+ /* Scheme, hostname port and local part. The filter URI and the >+ * URI we test may have the followin shapes: >+ * /<path> >+ * <scheme>[:://<hostname>[:<port>][/<path>]] >+ * That is, if there is no scheme then there must be only the path, >+ * and we check only the path; if there is a scheme, we check the >+ * scheme for equality, and then if present we match the hostname, >+ * and then if present match the port, and finally the path if any. >+ * >+ * Note that this means that "/<path>" only matches local paths, >+ * and to match proxied paths one *must* specify the scheme. >+ */ > >- /* Compare the ports */ >- if(filter.port_str) { >- if (url.port_str && filter.port != url.port) { >- return 0; >- } >- /* NOTE: ap_port_of_scheme will return 0 if given NULL input */ >- else if (filter.port != apr_uri_port_of_scheme(url.scheme)) { >- return 0; >- } >- } >- else if(url.port_str && filter.scheme) { >- if (apr_uri_port_of_scheme(filter.scheme) == url.port) { >- return 0; >- } >+ /* Is the filter is just for a local path or a proxy URI? */ >+ >+ if (filter.scheme == 0) { >+ if (url.scheme != 0 || url.hostname != 0 || url.port_str != 0) >+ return 0; >+ } else { >+ /* The URI scheme must be present and identical except for case. */ >+ if (url.scheme == 0 || strcasecmp(filter.scheme,url.scheme) != 0) >+ return 0; >+ >+ /* If the filter hostname is null or empty is matches any hostname, >+ * if it begins with a "*" it matches the _end_ of the URI hostname >+ * excluding the "*", if it begins with a "." it matches the _end_ >+ * of the URI * hostname including the ".", otherwise it must match >+ * the URI hostname exactly. */ >+ >+ if (filter.hostname != 0 && filter.hostname[0] != '\0') { >+ if (filter.hostname[0] == '.') { >+ const size_t fhostlen = strlen(filter.hostname); >+ const size_t uhostlen = strlen(url.hostname); >+ >+ if (fhostlen > uhostlen >+ || strcasecmp(filter.hostname, >+ url.hostname+uhostlen-fhostlen) != 0) >+ return 0; >+ } else if (filter.hostname[0] == '*') { >+ const size_t fhostlen = strlen(filter.hostname+1); >+ const size_t uhostlen = strlen(url.hostname); >+ >+ if (fhostlen > uhostlen >+ || strcasecmp(filter.hostname+1, >+ url.hostname+uhostlen-fhostlen) != 0) >+ return 0; >+ } else if (strcasecmp(filter.hostname,url.hostname) != 0) >+ return 0; >+ } >+ >+ >+ /* If the filter port is empty it matches any URL port. >+ * If the filter or URL port are missing, or the URL port is >+ * empty, they default to the port for their scheme. */ >+ >+ if (!(filter.port_str != 0 && filter.port_str[0] == '\0')) { >+ /* NOTE: ap_port_of_scheme will return 0 if given NULL input */ >+ const unsigned fport = (filter.port_str != 0) >+ ? filter.port : apr_uri_port_of_scheme(filter.scheme); >+ const unsigned uport = >+ (url.port_str != 0 && url.port_str[0] != '\0') >+ ? url.port : apr_uri_port_of_scheme(url.scheme); >+ >+ if (fport != uport) >+ return 0; >+ } > } > >- /* Url has met all of the filter conditions so far, determine >- * if the paths match. >- */ >- return !strncmp(filter.path, url.path, pathlen); >+ return strncmp(filter.path,url.path,pathlen) == 0; > } > > CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r, >@@ -82,7 +116,7 @@ > for (i = 0; i < conf->cacheenable->nelts; i++) { > struct cache_enable *ent = > (struct cache_enable *)conf->cacheenable->elts; >- if (uri_meets_conditions(ent[i].url, ent[i].pathlen, uri)) { >+ if (uri_meets_conditions(r->server,ent[i].url, ent[i].pathlen, uri)) { > /* Fetch from global config and add to the list. */ > cache_provider *provider; > provider = ap_lookup_provider(CACHE_PROVIDER_GROUP, ent[i].type, >@@ -119,7 +153,7 @@ > for (i = 0; i < conf->cachedisable->nelts; i++) { > struct cache_disable *ent = > (struct cache_disable *)conf->cachedisable->elts; >- if (uri_meets_conditions(ent[i].url, ent[i].pathlen, uri)) { >+ if (uri_meets_conditions(r->server,ent[i].url, ent[i].pathlen, uri)) { > /* Stop searching now. */ > return NULL; > }
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 40169
:
18694
|
18695
| 18889