]> granicus.if.org Git - apache/commitdiff
* Remove all filters that are before the cache_out filter. This ensures
authorRuediger Pluem <rpluem@apache.org>
Wed, 26 Jul 2006 17:33:38 +0000 (17:33 +0000)
committerRuediger Pluem <rpluem@apache.org>
Wed, 26 Jul 2006 17:33:38 +0000 (17:33 +0000)
  that we kick off the filter stack with our cache_out filter being the
  first in the chain. This make sense because we want to restore things
  in the same manner as we saved them.
  There may be filters before our cache_out filter, because

  1. We call ap_set_content_type during cache_select. This causes
     Content-Type specific filters to be added.
  2. We call the insert_filter hook. This causes filters e.g. like
     the ones set with SetOutputFilter to be added.

PR: 40090

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@425787 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/cache/mod_cache.c

diff --git a/CHANGES b/CHANGES
index 0a036384caad5e6ebfc6c46e9ecc55733c989868..f771b806362b84453a4ea5ec40e508f82c3b10ab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) mod_cache: While serving a cached entity ensure that filters that have
+     been applied to this cached entity before saving it to the cache are not
+     applied again. PR 40090. [Ruediger Pluem]
+
   *) mod_proxy_ajp: Added cping/cpong support for the AJP protocol.
      A new worker directive ping=timeout will cause CPING packet
      to be send expecting CPONG packet within defined timeout.
index 881cbf743f9df5fc4dc9d68f7c44dce7627bb40d..2fc50733f0050ecb117ae29c51f8368758d09d63 100644 (file)
@@ -56,6 +56,8 @@ static int cache_url_handler(request_rec *r, int lookup)
     cache_request_rec *cache;
     cache_server_conf *conf;
     apr_bucket_brigade *out;
+    ap_filter_t *next;
+    ap_filter_rec_t *cache_out_handle;
 
     /* Delay initialization until we know we are handling a GET */
     if (r->method_number != M_GET) {
@@ -213,12 +215,29 @@ static int cache_url_handler(request_rec *r, int lookup)
      * or not.
      */
     if (r->main) {
-        ap_add_output_filter_handle(cache_out_subreq_filter_handle, NULL,
-                                    r, r->connection);
+        cache_out_handle = cache_out_subreq_filter_handle;
     }
     else {
-        ap_add_output_filter_handle(cache_out_filter_handle, NULL,
-                                    r, r->connection);
+        cache_out_handle = cache_out_filter_handle;
+    }
+    ap_add_output_filter_handle(cache_out_handle, NULL, r, r->connection);
+
+    /*
+     * Remove all filters that are before the cache_out filter. This ensures
+     * that we kick off the filter stack with our cache_out filter being the
+     * first in the chain. This make sense because we want to restore things
+     * in the same manner as we saved them.
+     * There may be filters before our cache_out filter, because
+     *
+     * 1. We call ap_set_content_type during cache_select. This causes
+     *    Content-Type specific filters to be added.
+     * 2. We call the insert_filter hook. This causes filters e.g. like
+     *    the ones set with SetOutputFilter to be added.
+     */
+    next = r->output_filters;
+    while (next && (next->frec != cache_out_handle)) {
+        ap_remove_output_filter(next);
+        next = next->next;
     }
 
     /* kick off the filter stack */