You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2005/09/19 14:10:43 UTC
svn commit: r290133 - in /httpd/httpd: branches/2.2.x/
branches/2.2.x/modules/cache/ trunk/
Author: colm
Date: Mon Sep 19 05:10:34 2005
New Revision: 290133
URL: http://svn.apache.org/viewcvs?rev=290133&view=rev
Log:
Backport r239420 and r239421 to the 2.2.x branch; Enhance
CacheEnable/CacheDisable to be of use to proxy servers.
Modified:
httpd/httpd/branches/2.2.x/CHANGES
httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c
httpd/httpd/branches/2.2.x/modules/cache/cache_util.c
httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c
httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h
httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c
httpd/httpd/trunk/CHANGES
Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/CHANGES?rev=290133&r1=290132&r2=290133&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Mon Sep 19 05:10:34 2005
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with Apache 2.1.8
+ *) mod_cache: Enhance CacheEnable/CacheDisable to control caching on a
+ per-protocol, per-host and per-path basis. Intended for proxy
+ configurations. [Colm MacCarthaigh]
+
*) mod_disk_cache: Canonicalise the storage key, for improved hit/miss
ratio. [Colm MacCarthaigh]
Modified: httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c?rev=290133&r1=290132&r2=290133&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c Mon Sep 19 05:10:34 2005
@@ -169,7 +169,7 @@
* This function returns OK if successful, DECLINED if no
* cached entity fits the bill.
*/
-int cache_select_url(request_rec *r, char *url)
+int cache_select(request_rec *r)
{
cache_provider_list *list;
apr_status_t rv;
@@ -245,7 +245,7 @@
/* headers do not match, so Vary failed */
ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS,
r->server,
- "cache_select_url(): Vary header mismatch.");
+ "cache_select(): Vary header mismatch.");
return DECLINED;
}
}
Modified: httpd/httpd/branches/2.2.x/modules/cache/cache_util.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/cache_util.c?rev=290133&r1=290132&r2=290133&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/cache_util.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/cache_util.c Mon Sep 19 05:10:34 2005
@@ -24,23 +24,65 @@
extern module AP_MODULE_DECLARE_DATA cache_module;
+/* Determine if "url" matches the hostname, scheme and port and path
+ * in "filter". All but the path comparisons are case-insensitive.
+ */
+static int uri_meets_conditions(apr_uri_t filter, int pathlen, apr_uri_t url)
+{
+ /* Compare the hostnames */
+ if(filter.hostname) {
+ if (!url.hostname) {
+ return 0;
+ }
+ else if (strcasecmp(filter.hostname, url.hostname)) {
+ return 0;
+ }
+ }
+
+ /* Compare the schemes */
+ if(filter.scheme) {
+ if (!url.scheme) {
+ return 0;
+ }
+ else if (strcasecmp(filter.scheme, url.scheme)) {
+ return 0;
+ }
+ }
+
+ /* 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;
+ }
+ }
+
+ /* Url has met all of the filter conditions so far, determine
+ * if the paths match.
+ */
+ return !strncmp(filter.path, url.path, pathlen);
+}
CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r,
cache_server_conf *conf,
- const char *url)
+ apr_uri_t uri)
{
cache_provider_list *providers = NULL;
int i;
- /* we can't cache if there's no URL */
- /* Is this case even possible?? */
- if (!url) return NULL;
-
/* loop through all the cacheenable entries */
for (i = 0; i < conf->cacheenable->nelts; i++) {
struct cache_enable *ent =
(struct cache_enable *)conf->cacheenable->elts;
- if ((ent[i].url) && !strncasecmp(url, ent[i].url, ent[i].urllen)) {
+ if (uri_meets_conditions(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,
@@ -77,7 +119,7 @@
for (i = 0; i < conf->cachedisable->nelts; i++) {
struct cache_disable *ent =
(struct cache_disable *)conf->cachedisable->elts;
- if ((ent[i].url) && !strncasecmp(url, ent[i].url, ent[i].urllen)) {
+ if (uri_meets_conditions(ent[i].url, ent[i].pathlen, uri)) {
/* Stop searching now. */
return NULL;
}
Modified: httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c?rev=290133&r1=290132&r2=290133&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c Mon Sep 19 05:10:34 2005
@@ -50,11 +50,7 @@
{
apr_status_t rv;
const char *auth;
- apr_uri_t uri;
- char *url;
- char *path;
cache_provider_list *providers;
- cache_info *info;
cache_request_rec *cache;
cache_server_conf *conf;
apr_bucket_brigade *out;
@@ -64,18 +60,13 @@
return DECLINED;
}
- uri = r->parsed_uri;
- url = r->unparsed_uri;
- path = uri.path;
- info = NULL;
-
conf = (cache_server_conf *) ap_get_module_config(r->server->module_config,
&cache_module);
/*
* Which cache module (if any) should handle this request?
*/
- if (!(providers = ap_cache_get_providers(r, conf, path))) {
+ if (!(providers = ap_cache_get_providers(r, conf, r->parsed_uri))) {
return DECLINED;
}
@@ -114,7 +105,7 @@
* add cache_out filter
* return OK
*/
- rv = cache_select_url(r, url);
+ rv = cache_select(r);
if (rv != OK) {
if (rv == DECLINED) {
if (!lookup) {
@@ -219,7 +210,7 @@
* restore the status into it's handle. */
r->status = cache->handle->cache_obj->info.status;
- /* recall_headers() was called in cache_select_url() */
+ /* recall_headers() was called in cache_select() */
cache->provider->recall_body(cache->handle, r->pool, bb);
/* This filter is done once it has served up its content */
@@ -988,8 +979,15 @@
&cache_module);
new = apr_array_push(conf->cacheenable);
new->type = type;
- new->url = url;
- new->urllen = strlen(url);
+ if (apr_uri_parse(parms->pool, url, &(new->url))) {
+ return NULL;
+ }
+ if (new->url.path) {
+ new->pathlen = strlen(new->url.path);
+ } else {
+ new->pathlen = 1;
+ new->url.path = "/";
+ }
return NULL;
}
@@ -1003,8 +1001,15 @@
(cache_server_conf *)ap_get_module_config(parms->server->module_config,
&cache_module);
new = apr_array_push(conf->cachedisable);
- new->url = url;
- new->urllen = strlen(url);
+ if (apr_uri_parse(parms->pool, url, &(new->url))) {
+ return NULL;
+ }
+ if (new->url.path) {
+ new->pathlen = strlen(new->url.path);
+ } else {
+ new->pathlen = 1;
+ new->url.path = "/";
+ }
return NULL;
}
Modified: httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h?rev=290133&r1=290132&r2=290133&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h Mon Sep 19 05:10:34 2005
@@ -104,14 +104,15 @@
#endif
struct cache_enable {
- const char *url;
+ apr_uri_t url;
const char *type;
apr_size_t urllen;
+ apr_size_t pathlen;
};
struct cache_disable {
- const char *url;
- apr_size_t urllen;
+ apr_uri_t url;
+ apr_size_t pathlen;
};
/* static information about the local cache */
@@ -257,7 +258,7 @@
CACHE_DECLARE(char *) ap_cache_generate_name(apr_pool_t *p, int dirlevels,
int dirlength,
const char *name);
-CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r, cache_server_conf *conf, const char *url);
+CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r, cache_server_conf *conf, apr_uri_t uri);
CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
const char *key, char **val);
CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str);
@@ -274,7 +275,7 @@
*/
int cache_remove_url(cache_request_rec *cache, apr_pool_t *p);
int cache_create_entity(request_rec *r, char *url, apr_off_t size);
-int cache_select_url(request_rec *r, char *url);
+int cache_select(request_rec *r);
apr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key );
/**
* create a key for the cache based on the request record
Modified: httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c?rev=290133&r1=290132&r2=290133&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/mod_disk_cache.c Mon Sep 19 05:10:34 2005
@@ -981,7 +981,7 @@
}
/* Parse the vary header and dump those fields from the headers_in. */
- /* FIXME: Make call to the same thing cache_select_url calls to crack Vary. */
+ /* FIXME: Make call to the same thing cache_select calls to crack Vary. */
if (r->headers_in) {
apr_table_t *headers_in;
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/CHANGES?rev=290133&r1=290132&r2=290133&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Sep 19 05:10:34 2005
@@ -35,16 +35,16 @@
listening ports upon graceful restart or stop. PR 28167.
[Colm MacCarthaigh, Brian Pinkerton <bp thinkpink.com>]
- *) mod_cache: Enhance CacheEnable/CacheDisable to control caching on a
- per-protocol, per-host and per-path basis. Intended for proxy
- configurations. [Colm MacCarthaigh]
-
*) Teach mod_ssl to use arbitrary OIDs in an SSLRequire directive,
allowing string-valued client certificate attributes to be used for
access control, as in: SSLRequire "value" in OID("1.3.6.1.4.1.18060.1")
[Martin Kraemer, David Reid]
Changes with Apache 2.1.8
+
+ *) mod_cache: Enhance CacheEnable/CacheDisable to control caching on a
+ per-protocol, per-host and per-path basis. Intended for proxy
+ configurations. [Colm MacCarthaigh]
*) mod_disk_cache: Canonicalise the storage key, for improved hit/miss
ratio. [Colm MacCarthaigh]