From c88044c8cb2323202b3770ab8556907ca3e9449e Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 15 Sep 2010 19:33:18 +0000 Subject: Forcibly invalidate contents with response codes that aren't 200 or 203. svn path=/trunk/netsurf/; revision=10780 --- content/llcache.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'content/llcache.c') diff --git a/content/llcache.c b/content/llcache.c index a4dd96d27..56219f8e9 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -1648,17 +1648,33 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, break; case FETCH_DATA: /* Received some data */ - object->fetch.state = LLCACHE_FETCH_DATA; - if (object->has_query && (object->cache.expires == 0 && - object->cache.max_age == INVALID_AGE)) { - /* URI had query string and did not provide an explicit - * expiration time, thus by rfc2616 13.9 we must - * invalidate the cache data to force the cache to not - * retain the object. + if (object->fetch.state != LLCACHE_FETCH_DATA) { + /* On entry into this state, check if we need to + * invalidate the cache control data. We are guaranteed + * to have received all response headers. + * + * There are two cases in which we want to suppress + * cacheing of an object: + * + * 1) The HTTP response code is not 200 or 203 + * 2) The request URI had a query string and the + * response headers did not provide an explicit + * object expiration time. */ - memset(&(object->cache), 0, - sizeof(llcache_cache_control)); + long http_code = fetch_http_code(object->fetch.fetch); + + if ((http_code != 200 && http_code != 203) && + (object->has_query && + (object->cache.max_age == INVALID_AGE && + object->cache.expires == 0))) { + /* Invalidate cache control data */ + memset(&(object->cache), 0, + sizeof(llcache_cache_control)); + } } + + object->fetch.state = LLCACHE_FETCH_DATA; + error = llcache_fetch_process_data(object, data, size); break; case FETCH_FINISHED: -- cgit v1.2.3