summaryrefslogtreecommitdiff
path: root/content/llcache.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-02-17 17:50:14 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-02-17 17:50:14 +0000
commitd8d0353a734767fcc1211b922820a59303e810a5 (patch)
treee01366a539949ee752da261f1c76c430d6f15164 /content/llcache.c
parentf9f1c0c3b30eefc18d10fe36be291aa9b8250c77 (diff)
downloadnetsurf-d8d0353a734767fcc1211b922820a59303e810a5.tar.gz
netsurf-d8d0353a734767fcc1211b922820a59303e810a5.tar.bz2
Fix bug #3184972: cope with server sending a 304 in response to an unconditional request.
svn path=/trunk/netsurf/; revision=11710
Diffstat (limited to 'content/llcache.c')
-rw-r--r--content/llcache.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/content/llcache.c b/content/llcache.c
index cf409849a..64e37915a 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -2064,23 +2064,38 @@ nserror llcache_fetch_redirect(llcache_object *object, const char *target,
nserror llcache_fetch_notmodified(llcache_object *object,
llcache_object **replacement)
{
- llcache_object_user *user, *next;
+ /* There may be no candidate if the server erroneously responded
+ * to an unconditional request with a 304 Not Modified response.
+ * In this case, we simply retain the initial object, having
+ * invalidated it and marked it as complete.
+ */
+ if (object->candidate != NULL) {
+ llcache_object_user *user, *next;
- /* Move user(s) to candidate content */
- for (user = object->users; user != NULL; user = next) {
- next = user->next;
+ /* Move user(s) to candidate content */
+ for (user = object->users; user != NULL; user = next) {
+ next = user->next;
- llcache_object_remove_user(object, user);
- llcache_object_add_user(object->candidate, user);
- }
+ llcache_object_remove_user(object, user);
+ llcache_object_add_user(object->candidate, user);
+ }
+
+ /* Candidate is no longer a candidate for us */
+ object->candidate->candidate_count--;
- /* Candidate is no longer a candidate for us */
- object->candidate->candidate_count--;
+ /* Clone our cache control data into the candidate */
+ llcache_object_clone_cache_data(object, object->candidate,
+ false);
+ /* Bring candidate's cache data up to date */
+ llcache_object_cache_update(object->candidate);
- /* Clone our cache control data into the candidate */
- llcache_object_clone_cache_data(object, object->candidate, false);
- /* Bring candidate's cache data up to date */
- llcache_object_cache_update(object->candidate);
+ /* Candidate is now our object */
+ *replacement = object->candidate;
+ object->candidate = NULL;
+ } else {
+ /* There was no candidate: retain object */
+ *replacement = object;
+ }
/* Ensure fetch has stopped */
fetch_abort(object->fetch.fetch);
@@ -2092,10 +2107,6 @@ nserror llcache_fetch_notmodified(llcache_object *object,
/* Mark it complete */
object->fetch.state = LLCACHE_FETCH_COMPLETE;
- /* Candidate is now our object */
- *replacement = object->candidate;
- object->candidate = NULL;
-
/* Old object will be flushed from the cache on the next poll */
return NSERROR_OK;