You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rp...@apache.org on 2007/02/12 21:29:04 UTC

svn commit: r506621 - in /httpd/httpd/trunk: CHANGES modules/cache/cache_storage.c modules/cache/mod_cache.h

Author: rpluem
Date: Mon Feb 12 12:29:04 2007
New Revision: 506621

URL: http://svn.apache.org/viewvc?view=rev&rev=506621
Log:
* 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

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/cache/cache_storage.c
    httpd/httpd/trunk/modules/cache/mod_cache.h

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?view=diff&rev=506621&r1=506620&r2=506621
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Feb 12 12:29:04 2007
@@ -2,6 +2,9 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) 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>]
 

Modified: httpd/httpd/trunk/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.c?view=diff&rev=506621&r1=506620&r2=506621
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.c Mon Feb 12 12:29:04 2007
@@ -346,10 +346,30 @@
                                         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.
@@ -456,6 +476,16 @@
         *key = apr_pstrcat(p, scheme, "://", hostname, port_str,
                            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;
 }

Modified: httpd/httpd/trunk/modules/cache/mod_cache.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.h?view=diff&rev=506621&r1=506620&r2=506621
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.h (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.h Mon Feb 12 12:29:04 2007
@@ -249,6 +249,9 @@
     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;