From b1e0a711c798c48059c5d40835649c84e109d056 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 6 Jan 2016 23:53:02 +0000 Subject: Stop reporting error from mime sniffing when a fetcher completes with no data If a fetcher returns with no data (no content or http error code 204) the hlcache state machine was trying to mimesniff using non existent header data and reporting the resulting NSERROR_NOT_FOUND as a "BadType" message. This changes the behaviour to be similar to that in the headers received case where NSERROR_NOT_FOUND from the mimesniffing is not an error. --- content/hlcache.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/content/hlcache.c b/content/hlcache.c index 85567f5a4..3f0e810a5 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -464,10 +464,12 @@ static nserror hlcache_llcache_callback(llcache_handle *handle, */ error = mimesniff_compute_effective_type(handle, NULL, 0, false, false, &effective_type); - if (error == NSERROR_OK) { + if (error == NSERROR_OK || error == NSERROR_NOT_FOUND) { error = hlcache_migrate_ctx(ctx, effective_type); - lwc_string_unref(effective_type); + if (effective_type != NULL) { + lwc_string_unref(effective_type); + } return error; } @@ -475,8 +477,8 @@ static nserror hlcache_llcache_callback(llcache_handle *handle, if (ctx->handle->cb != NULL) { hlcache_event hlevent; - hlevent.type = CONTENT_MSG_ERROR; - hlevent.data.error = messages_get("BadType"); + hlevent.type = CONTENT_MSG_ERRORCODE; + hlevent.data.errorcode = error; ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw); } -- cgit v1.2.3