From: Stefan Fritsch Date: Tue, 29 May 2012 19:55:37 +0000 (+0000) Subject: Merge r933919, r951222: X-Git-Tag: 2.2.23~165 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2b8a553a5a86809c860795a4b490d8f8e53099ff;p=thirdparty%2Fapache%2Fhttpd.git Merge r933919, r951222: * Do not cache 206 responses in any case since we currently do not provide any backends that are capable to cache partial responses. PR 49113. Fixes regression of r724093. Submitted by: minfrin Reviewed by: rjung, wrowe, sf git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1343951 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 5160517e286..4bbcac36401 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,11 @@ Changes with Apache 2.2.23 envvars: Fix insecure handling of LD_LIBRARY_PATH that could lead to the current working directory to be searched for DSOs. [Stefan Fritsch] + *) mod_disk_cache, mod_mem_cache: Decline the opportunity to cache if the + response is a 206 Partial Content. This stops a reverse proxied partial + response from becoming cached, and then being served in subsequent + responses. [Graham Leggett] + *) configure: Fix usage with external apr and apu in non-default paths and recent gcc versions >= 4.6. [Jean-Frederic Clere] diff --git a/STATUS b/STATUS index bfcf509ce57..5fd07b82a33 100644 --- a/STATUS +++ b/STATUS @@ -93,20 +93,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_cache: * Do not cache 206 responses in any case since we currently do not provide any - backends that are capable to cache partial responses. PR 49113. - Fixes regression of r724093. - Trunk version of patch: - http://svn.apache.org/viewcvs.cgi?rev=933919&view=rev - Backport version for 2.2.x of patch: - Trunk version of patch works - +1: rpluem - minfrin: The r933919 patch is obsolete, as this trunk code no longer - exists. The fix you're after is r951222, backported to both - mod_disk_cache.c and mod_mem_cache.c. - rjung: I combined backports of r933919 and r951222: - http://people.apache.org/~rjung/patches/mod_cache_partial_content-2.2.x.patch - +1: rjung, wrowe, sf PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 8aeb3f73ca7..2f649ef2dbb 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -473,7 +473,8 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) * We include 304 Not Modified here too as this is the origin server * telling us to serve the cached copy. */ - if (exps != NULL || cc_out != NULL) { + if ((exps != NULL || cc_out != NULL) + && r->status != HTTP_PARTIAL_CONTENT) { /* We are also allowed to cache any response given that it has a * valid Expires or Cache Control header. If we find a either of * those here, we pass request through the rest of the tests. From @@ -486,6 +487,9 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) * include the following: an Expires header (section 14.21); a * "max-age", "s-maxage", "must-revalidate", "proxy-revalidate", * "public" or "private" cache-control directive (section 14.9). + * + * But do NOT store 206 responses in any case since we + * don't (yet) cache partial responses. */ } else { diff --git a/modules/cache/mod_disk_cache.c b/modules/cache/mod_disk_cache.c index f13800b3067..13d6c8b300b 100644 --- a/modules/cache/mod_disk_cache.c +++ b/modules/cache/mod_disk_cache.c @@ -330,6 +330,14 @@ static int create_entity(cache_handle_t *h, request_rec *r, const char *key, apr return DECLINED; } + /* we don't support caching of range requests (yet) */ + if (r->status == HTTP_PARTIAL_CONTENT) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, + "disk_cache: URL %s partial content response not cached", + key); + return DECLINED; + } + /* Allocate and initialize cache_object_t and disk_cache_object_t */ h->cache_obj = obj = apr_pcalloc(r->pool, sizeof(*obj)); obj->vobj = dobj = apr_pcalloc(r->pool, sizeof(*dobj)); diff --git a/modules/cache/mod_mem_cache.c b/modules/cache/mod_mem_cache.c index 38aa8f84668..b845b98330a 100644 --- a/modules/cache/mod_mem_cache.c +++ b/modules/cache/mod_mem_cache.c @@ -313,6 +313,14 @@ static int create_entity(cache_handle_t *h, cache_type_e type_e, cache_object_t *obj, *tmp_obj; mem_cache_object_t *mobj; + /* we don't support caching of range requests (yet) */ + if (r->status == HTTP_PARTIAL_CONTENT) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, + "disk_cache: URL %s partial content response not cached", + key); + return DECLINED; + } + if (len == -1) { /* Caching a streaming response. Assume the response is * less than or equal to max_streaming_buffer_size. We will