Handle zero-length documents correctly

svn path=/trunk/netsurf/; revision=12778
This commit is contained in:
John Mark Bell 2011-09-08 08:26:16 +00:00
parent c25d7890e7
commit f6ac059a05
2 changed files with 37 additions and 2 deletions

View File

@ -491,9 +491,26 @@ nserror hlcache_llcache_callback(llcache_handle *handle,
break;
case LLCACHE_EVENT_DONE:
/* DONE event before we could determine the effective MIME type.
* Treat this as an error.
*/
/* Fall through */
error = mimesniff_compute_effective_type(handle,
NULL, 0, false, &effective_type);
if (error == NSERROR_OK) {
error = hlcache_migrate_ctx(ctx, effective_type);
lwc_string_unref(effective_type);
return error;
}
if (ctx->handle->cb != NULL) {
hlcache_event hlevent;
hlevent.type = CONTENT_MSG_ERROR;
hlevent.data.error = messages_get("BadType");
ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
}
break;
case LLCACHE_EVENT_ERROR:
if (ctx->handle->cb != NULL) {
hlcache_event hlevent;

View File

@ -1444,6 +1444,15 @@ nserror llcache_object_notify_users(llcache_object *object)
if (error != NSERROR_OK)
return error;
continue;
} else if (error == NSERROR_NEED_DATA) {
/* User requested replay */
handle->state = LLCACHE_FETCH_HEADERS;
/* Continue with the next user -- we'll
* reemit the event next time round */
user->iterator_target = false;
next_user = user->next;
continue;
} else if (error != NSERROR_OK) {
user->iterator_target = false;
@ -1521,6 +1530,15 @@ nserror llcache_object_notify_users(llcache_object *object)
if (error != NSERROR_OK)
return error;
continue;
} else if (error == NSERROR_NEED_DATA) {
/* User requested replay */
handle->state = LLCACHE_FETCH_DATA;
/* Continue with the next user -- we'll
* reemit the event next time round */
user->iterator_target = false;
next_user = user->next;
continue;
} else if (error != NSERROR_OK) {
user->iterator_target = false;