]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* mod_cache: Preserve the Content-Type in case of 304 response.
authorJan Kaluža <jkaluza@apache.org>
Mon, 9 Mar 2015 12:48:11 +0000 (12:48 +0000)
committerJan Kaluža <jkaluza@apache.org>
Mon, 9 Mar 2015 12:48:11 +0000 (12:48 +0000)
304 does not contain Content-Type and mod_mime regenerates
the Content-Type based on the r->filename. This later leads to original
Content-Type to be lost (overwriten by whatever mod_mime generates).

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

modules/cache/mod_cache.c

index 5f478cd876f9fd61f633887e2c3d7e61df9fa31f..d84448d7f66d56af8de73c6bad8e739fe5720bac 100644 (file)
@@ -973,12 +973,20 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
     /* 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 = cache_table_getm(r->pool, cache->stale_handle->resp_hdrs,
-                "Cache-Control");
-        pragma = cache_table_getm(r->pool, cache->stale_handle->resp_hdrs,
-                "Pragma");
+    if (r->status == HTTP_NOT_MODIFIED && cache->stale_handle) {
+        if (!cc_out && !pragma) {
+            cc_out = cache_table_getm(r->pool, cache->stale_handle->resp_hdrs,
+                    "Cache-Control");
+            pragma = cache_table_getm(r->pool, cache->stale_handle->resp_hdrs,
+                    "Pragma");
+        }
+
+        /* 304 does not contain Content-Type and mod_mime regenerates the
+         * Content-Type based on the r->filename. This would lead to original
+         * Content-Type to be lost (overwriten by whatever mod_mime generates).
+         * We preserves the original Content-Type here. */
+        ap_set_content_type(r, apr_table_get(
+                cache->stale_handle->resp_hdrs, "Content-Type"));
     }
 
     /* Parse the cache control header */