From: Jan Kaluža Date: Mon, 9 Mar 2015 12:48:11 +0000 (+0000) Subject: * mod_cache: Preserve the Content-Type in case of 304 response. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3379d61343cd6905efbb88d3d0cfe347bc76ea35;p=thirdparty%2Fapache%2Fhttpd.git * mod_cache: Preserve the Content-Type in case of 304 response. 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 --- diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 5f478cd876f..d84448d7f66 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -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 */