]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r506621 from trunk:
authorRuediger Pluem <rpluem@apache.org>
Thu, 17 May 2007 21:03:04 +0000 (21:03 +0000)
committerRuediger Pluem <rpluem@apache.org>
Thu, 17 May 2007 21:03:04 +0000 (21:03 +0000)
* Save the key we generate during our first run of cache_generate_key_default
  on each request in the request_config. During consecutive runs of
  cache_generate_key_default during processing the request we restore it
  from there as we might not be able to generate the same key again as
  the ingredients used to compose the key might have changed and we constantly
  must use a key that could be generated during the quick handler phase.

PR: 41475

Submitted by: rpluem
Reviewed by: rpluem, jerenkrantz, jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@539112 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/cache/cache_storage.c
modules/cache/mod_cache.h

diff --git a/CHANGES b/CHANGES
index 5f1e6843185dd50f116a40a99adb33efba844cd4..1d4fca1e2410d3df8fdcbbab56784f7fbc81e095 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.5
 
+  *) mod_cache: Use the same cache key throughout the whole request processing
+     to handle escaped URLs correctly.  PR 41475. [Ruediger Pluem]
+
   *) mod_cache: Add CacheIgnoreQueryString directive.  PR 41484.
      [Fredrik Widlund <fredrik.widlund qbrick.com>]
 
diff --git a/STATUS b/STATUS
index 9a6b2bc829cb2be5e89acb1c29a1b5064ef6a6c1..823b59c4805ad8443bcb1d4b5ee4a8a7c246ea9f 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -105,30 +105,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
      http://svn.apache.org/viewvc?view=rev&rev=520733
      +1: wrowe, rpluem, niq
 
-   * mod_cache: Correctly cache and recall entities whose request URL's
-     are url-escaped.
-        PR: 41475
-     Trunk version of patch:
-       http://svn.apache.org/viewvc?view=rev&revision=506621
-     2.2.x version of patch:
-       Trunk version works
-     +1: rpluem, jerenkrantz, jim
-         wrowe asks - is there a disambiguation problem here?  The items
-         in the cache should either entirely be escaped or unescaped.
-         Can't violate the applicable canonicalization.  However, if this
-         simply allows escaped entities that are unambiguously their
-         non-path, special values, (e.g. '/' vs %2F the character)
-         then I'm strongly +1.
-         rpluem says: Sorry for the confusing title. This is more about
-         the fact that the URL of the request is subject to several
-         transformations that are applied *after* the quick handler phase
-         (unescaping, possibly mod_rewrite, etc.).
-         As we use the URL to calculate the cache key this can lead to situations
-         where we save an entity to the cache under a different key in the
-         CACHE_SAVE filter then the key we use to request the entity from the
-         cache during the quick handler phase. If there are still questions
-         we should continue the discussion on the list.
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
 
     * ApacheMonitor: Fix Windows Vista detection.
index f396ce8d3a3fceb8c4f49b3077e5f4783992fb67..f02f26f3ee0d23bc0a78fd7b868c56a946b3877a 100644 (file)
@@ -332,10 +332,30 @@ apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
                                         char**key)
 {
     cache_server_conf *conf;
+    cache_request_rec *cache;
     char *port_str, *hn, *lcs;
     const char *hostname, *scheme;
     int i;
 
+    cache = (cache_request_rec *) ap_get_module_config(r->request_config,
+                                                       &cache_module);
+    if (!cache) {
+        /* This should never happen */
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                     "cache: No cache request information available for key"
+                     " generation");
+        *key = "";
+        return APR_EGENERAL;
+    }
+    if (cache->key) {
+        /*
+         * We have been here before during the processing of this request.
+         * So return the key we already have.
+         */
+        *key = apr_pstrdup(p, cache->key);
+        return APR_SUCCESS;
+    }
+
     /*
      * Get the module configuration. We need this for the CacheIgnoreQueryString
      * option below.
@@ -443,5 +463,15 @@ apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
                            r->parsed_uri.path, "?", r->parsed_uri.query, NULL);
     }
 
+    /*
+     * Store the key in the request_config for the cache as r->parsed_uri
+     * might have changed in the time from our first visit here triggered by the
+     * quick handler and our possible second visit triggered by the CACHE_SAVE
+     * filter (e.g. r->parsed_uri got unescaped). In this case we would save the
+     * resource in the cache under a key where it is never found by the quick
+     * handler during following requests.
+     */
+    cache->key = apr_pstrdup(r->pool, *key);
+
     return APR_SUCCESS;
 }
index 308a70ab773e772ca652f45af0945484c392cfb6..4fe8dfc4d5cd337a9cbd5075f2f455a6c0cda0f1 100644 (file)
@@ -234,6 +234,9 @@ typedef struct {
     apr_time_t lastmod;                 /* last-modified time */
     cache_info *info;                   /* current cache info */
     ap_filter_t *remove_url_filter;     /* Enable us to remove the filter */
+    char *key;                          /* The cache key created for this
+                                         * request
+                                         */
 } cache_request_rec;