[whatwg/fetch] interop: content-type for blob fetch with invalid type (Issue #1693)

From [File API - Blob.type](https://w3c.github.io/FileAPI/#dfn-type):

> [...] the type of a [Blob](https://w3c.github.io/FileAPI/#dfn-Blob) as an ASCII-encoded string in lower case, such that when it is converted to a [byte](https://infra.spec.whatwg.org/#byte) sequence, it is a [parsable MIME type](https://mimesniff.spec.whatwg.org/#parsable-mime-type), or the empty string – 0 bytes – if the type cannot be determined.

Based on my reading of this, I'd expect that a fetch of blob created with an invalid mime type for `type` would result in the `Content-Type` set to the empty string (similar to a blob created without a input type https://github.com/whatwg/fetch/issues/1436).

Given the following test:

```
diff --git a/fetch/api/basic/scheme-blob.sub.any.js b/fetch/api/basic/scheme-blob.sub.any.js
index a6059ea93d..8afdc033c9 100644
--- a/fetch/api/basic/scheme-blob.sub.any.js
+++ b/fetch/api/basic/scheme-blob.sub.any.js
@@ -57,6 +57,10 @@ let empty_data_blob = new Blob([], {type: "text/plain"});
 checkFetchResponse(URL.createObjectURL(empty_data_blob), "", "text/plain", 0,
                   "Fetching URL.createObjectURL(empty_data_blob) is OK");

+let invalid_type_blob = new Blob([], {type: "invalid"});
+checkFetchResponse(URL.createObjectURL(invalid_type_blob), "", "", 0,
+                  "Fetching URL.createObjectURL(invalid_type_blob) is OK");
+
 promise_test(function(test) {
   return fetch("/images/blue.png").then(function(resp) {
     return resp.arrayBuffer();
```

I get the following results:

|Browser| Content-Type |
|--------|--------|
| Firefox | `"application/x-unknown-content-type"` |
| Chrome| `"invalid"` |
| Safari | `"invalid"` |

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1693
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1693@github.com>

Received on Monday, 7 August 2023 21:32:19 UTC