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.
This commit is contained in:
Vincent Sanders 2016-01-06 23:53:02 +00:00
parent 51de6c2e7c
commit b1e0a711c7
1 changed files with 6 additions and 4 deletions

View File

@ -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);
}