]> granicus.if.org Git - apache/commitdiff
mod_cache: Respect the original Cache-Control header if no header arrives
authorGraham Leggett <minfrin@apache.org>
Sat, 23 Oct 2010 14:11:20 +0000 (14:11 +0000)
committerGraham Leggett <minfrin@apache.org>
Sat, 23 Oct 2010 14:11:20 +0000 (14:11 +0000)
with a 304 Not Modified.

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

modules/cache/mod_cache.c

index bbdec894e1565bb20a1c1c22e8efe81979cb155d..8d1652486f7aa2979c3277a2c8429472d500034e 100644 (file)
@@ -868,12 +868,21 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
     cc_out = apr_table_get(r->err_headers_out, "Cache-Control");
     pragma = apr_table_get(r->err_headers_out, "Pragma");
     headers = r->err_headers_out;
-    if (cc_out == NULL && pragma == NULL) {
+    if (!cc_out && !pragma) {
         cc_out = apr_table_get(r->headers_out, "Cache-Control");
         pragma = apr_table_get(r->headers_out, "Pragma");
         headers = r->headers_out;
     }
 
+    /* Have we received a 304 response without any headers at all? Fall back to
+     * the original headers in the original cached request.
+     */
+    if (r->status == HTTP_NOT_MODIFIED && cache->stale_handle && !cc_out
+            && !pragma) {
+        cc_out = apr_table_get(cache->stale_handle->resp_hdrs, "Cache-Control");
+        pragma = apr_table_get(cache->stale_handle->resp_hdrs, "Pragma");
+    }
+
     /* Parse the cache control header */
     memset(&control, 0, sizeof(cache_control_t));
     ap_cache_control(r, &control, cc_out, pragma, headers);