diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2010-09-15 19:33:18 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2010-09-15 19:33:18 +0000 |
commit | c88044c8cb2323202b3770ab8556907ca3e9449e (patch) | |
tree | d5dc1aaf0f0796239473b056d37f65d5865defbb /content | |
parent | 805d6586d64ba4e3f748cca3c319559aad70d15f (diff) | |
download | netsurf-c88044c8cb2323202b3770ab8556907ca3e9449e.tar.gz netsurf-c88044c8cb2323202b3770ab8556907ca3e9449e.tar.bz2 |
Forcibly invalidate contents with response codes that aren't 200 or 203.
svn path=/trunk/netsurf/; revision=10780
Diffstat (limited to 'content')
-rw-r--r-- | content/llcache.c | 34 |
1 files changed, 25 insertions, 9 deletions
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: |