From: Yann Ylavic Date: Wed, 30 Apr 2014 14:53:35 +0000 (+0000) Subject: mod_cache: follow up to r1591320. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2a5c4641175f75e54d4840b67b94410862eafdf;p=thirdparty%2Fapache%2Fhttpd.git mod_cache: follow up to r1591320. Use the new MOD_CACHE_ENTITY_HEADERS[] names to check 304 contradictions against the same headers. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1591322 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 6908a0a2321..c2b92e9e8c1 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -772,17 +772,16 @@ static int cache_save_store(ap_filter_t *f, apr_bucket_brigade *in, /** * Sanity check for 304 Not Modified responses, as per RFC2616 Section 10.3.5. */ -static const char *cache_header_cmp(apr_pool_t *pool, apr_table_t *left, +static int cache_header_cmp(apr_pool_t *pool, apr_table_t *left, apr_table_t *right, const char *key) { const char *h1, *h2; if ((h1 = cache_table_getm(pool, left, key)) && (h2 = cache_table_getm(pool, right, key)) && (strcmp(h1, h2))) { - return apr_pstrcat(pool, "contradiction: 304 Not Modified, but ", key, - " modified", NULL); + return 1; } - return NULL; + return 0; } /* @@ -1129,29 +1128,22 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) else if (r->status == HTTP_NOT_MODIFIED && cache->stale_handle) { apr_table_t *left = cache->stale_handle->resp_hdrs; apr_table_t *right = r->headers_out; + const char *ehs = NULL; /* and lastly, contradiction checks for revalidated responses * as per RFC2616 Section 10.3.5 */ - if (((reason = cache_header_cmp(r->pool, left, right, "Allow"))) - || ((reason = cache_header_cmp(r->pool, left, right, - "Content-Encoding"))) - || ((reason = cache_header_cmp(r->pool, left, right, - "Content-Language"))) - || ((reason = cache_header_cmp(r->pool, left, right, - "Content-Length"))) - || ((reason = cache_header_cmp(r->pool, left, right, - "Content-Location"))) - || ((reason = cache_header_cmp(r->pool, left, right, - "Content-MD5"))) - || ((reason = cache_header_cmp(r->pool, left, right, - "Content-Range"))) - || ((reason = cache_header_cmp(r->pool, left, right, - "Content-Type"))) - || ((reason = cache_header_cmp(r->pool, left, right, "ETag"))) - || ((reason = cache_header_cmp(r->pool, left, right, - "Last-Modified")))) { - /* contradiction: 304 Not Modified, but entity header modified */ + if (cache_header_cmp(r->pool, left, right, "ETag")) { + ehs = (ehs) ? apr_pstrcat(r->pool, ehs, ", ETag", NULL) : "ETag"; + } + for (eh = MOD_CACHE_ENTITY_HEADERS; *eh && !reason; ++eh) { + if (cache_header_cmp(r->pool, left, right, *eh)) { + ehs = (ehs) ? apr_pstrcat(r->pool, ehs, ", ", *eh, NULL) : *eh; + } + } + if (ehs) { + reason = apr_pstrcat(r->pool, "contradiction: 304 Not Modified; " + "but ", ehs, " modified", NULL); } }