When calling .blob() on a Request or Response, the resulting Blob always has an empty type, regardless of the Content-Type header on the request/response.
Per the Fetch spec - consume body, the Blob's type should be set to the body's extracted MIME type — derived from the Content-Type header, ASCII-lowercased.
WPT coverage
fetch/api/body/mime-type.any.js has 20 tests covering this behaviour.
The file currently cannot run: it contains a top-level bodyContainer.clone() call that throws TypeError because Response.clone() is not yet implemented, which aborts the file before any tests are registered. Once Response.clone() is implemented, 14 of those 20 tests will fail due to this bug.
Root cause
In builtins/web/fetch/request-response.cpp, parse_body<BodyReadResult::Blob> hardcodes contentType to the empty string:
} else if constexpr (result_type == RequestOrResponse::BodyReadResult::Blob) {
JS::RootedString contentType(cx, JS_GetEmptyString(cx)); // always empty
JS::RootedObject blob(cx, blob::Blob::create(cx, std::move(buf), len, contentType));
Fix
The FormData branch immediately below already does the correct thing — reads the Content-Type header via Headers::lookup and calls extract_mime_type. The Blob branch needs the same treatment, with the result ASCII-lowercased before being passed to Blob::create. The absent-header case (where blob.type should remain "") is already handled correctly by the current fallback.
When calling
.blob()on aRequestorResponse, the resultingBlobalways has an emptytype, regardless of theContent-Typeheader on the request/response.Per the Fetch spec - consume body, the Blob's type should be set to the body's extracted MIME type — derived from the
Content-Typeheader, ASCII-lowercased.WPT coverage
fetch/api/body/mime-type.any.jshas 20 tests covering this behaviour.The file currently cannot run: it contains a top-level
bodyContainer.clone()call that throwsTypeErrorbecauseResponse.clone()is not yet implemented, which aborts the file before any tests are registered. OnceResponse.clone()is implemented, 14 of those 20 tests will fail due to this bug.Root cause
In
builtins/web/fetch/request-response.cpp,parse_body<BodyReadResult::Blob>hardcodescontentTypeto the empty string:Fix
The FormData branch immediately below already does the correct thing — reads the Content-Type header via Headers::lookup and calls extract_mime_type. The Blob branch needs the same treatment, with the result ASCII-lowercased before being passed to Blob::create. The absent-header case (where blob.type should remain "") is already handled correctly by the current fallback.