Fix bug #3184972: cope with server sending a 304 in response to an unconditional request.

svn path=/trunk/netsurf/; revision=11710
This commit is contained in:
John Mark Bell 2011-02-17 17:50:14 +00:00
parent f9f1c0c3b3
commit d8d0353a73
1 changed files with 29 additions and 18 deletions

View File

@ -2064,24 +2064,39 @@ 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--;
/* 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;
}
/* 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);
/* Ensure fetch has stopped */
fetch_abort(object->fetch.fetch);
object->fetch.fetch = NULL;
@ -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;