]> granicus.if.org Git - apache/commitdiff
mod_cache: Preserve non-cacheable headers forwarded from an origin 304
authorYann Ylavic <ylavic@apache.org>
Wed, 30 Apr 2014 14:58:33 +0000 (14:58 +0000)
committerYann Ylavic <ylavic@apache.org>
Wed, 30 Apr 2014 14:58:33 +0000 (14:58 +0000)
           response. PR 55547.

When mod_cache asks for a revalidation of a stale entry and the origin responds
with a 304 (not that stale), the module strips the non-cacheable headers from
the origin response and merges the stale headers to update the cache.

The problem is that mod_cache won't forward the non-cacheable headers to the
client, for example if the 304 response contains both Set-Cookie and
'Cache-Control: no-cache="Set-Cookie"' headers, or CacheIgnoreHeaders is used.

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

CHANGES
modules/cache/mod_cache.c

diff --git a/CHANGES b/CHANGES
index 0eafe9dc38b49800b40e55f34e63a6e3a6a9b448..267a90ae7bac21e3f2cbaaf7a4de5428641ed442 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_cache: Preserve non-cacheable headers forwarded from an origin 304
+                response. PR 55547. [Yann Ylavic]
+
   *) mod_cache: Don't add cached/revalidated entity headers to a 304 response.
                 PR 55547. [Yann Ylavic]
 
index c2b92e9e8c189424b794fc11f7745c79df047b7f..74c559c727e697b77cc908a46e8f1df59e7fe348 100644 (file)
@@ -1444,10 +1444,14 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
          * the cached headers.
          *
          * However, before doing that, we need to first merge in
-         * err_headers_out and we also need to strip any hop-by-hop
-         * headers that might have snuck in.
+         * err_headers_out (note that store_headers() below already selects
+         * the cacheable only headers using ap_cache_cacheable_headers_out(),
+         * here we want to keep the original headers in r->headers_out and
+         * forward all of them to the client, including non-cacheable ones).
          */
-        r->headers_out = ap_cache_cacheable_headers_out(r);
+        r->headers_out = apr_table_overlay(r->pool, r->headers_out,
+                                           r->err_headers_out);
+        apr_table_clear(r->err_headers_out);
 
         /* Merge in our cached headers.  However, keep any updated values. */
         /* take output, overlay on top of cached */