summaryrefslogtreecommitdiffstats
path: root/modules/cache
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2014-04-30 16:53:35 +0200
committerYann Ylavic <ylavic@apache.org>2014-04-30 16:53:35 +0200
commit0e28401e4500923bbc474d245178b2903cf2e9bb (patch)
treecefa17b3db0a013a44f43fe18eae9987323c85cc /modules/cache
parentmod_cache: Don't add cached/revalidated entity headers to a 304 response. (diff)
downloadapache2-0e28401e4500923bbc474d245178b2903cf2e9bb.tar.xz
apache2-0e28401e4500923bbc474d245178b2903cf2e9bb.zip
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
Diffstat (limited to 'modules/cache')
-rw-r--r--modules/cache/mod_cache.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c
index 6908a0a232..c2b92e9e8c 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);
}
}