diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2021-08-16 12:53:30 +0200 |
---|---|---|
committer | Luca Casonato <lucacasonato@yahoo.com> | 2021-08-16 19:45:37 +0200 |
commit | 6ced7b0383769807bdd864ebbf6a16a418d3f821 (patch) | |
tree | 13a5010e4a67edf7a42d4046cc0205b3ad1c5d09 /ext/fetch/26_fetch.js | |
parent | 6ddabb742757e1031f04b896c6f319dd0dadbc73 (diff) |
fix(ext/fetch): better error if no content-type
The streaming WASM support code inspects the Response object's
Content-Type header but if that was missing, it failed with a fairly
inscrutable "String.prototype.toLowerCase called on null or undefined"
exception. Now it raises a more legible "Invalid WebAssembly content
type" exception.
Diffstat (limited to 'ext/fetch/26_fetch.js')
-rw-r--r-- | ext/fetch/26_fetch.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 2d7180691..edd14abf1 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -503,9 +503,10 @@ // The spec is ambiguous here, see // https://github.com/WebAssembly/spec/issues/1138. The WPT tests // expect the raw value of the Content-Type attribute lowercased. + const contentType = res.headers.get("Content-Type"); if ( - StringPrototypeToLowerCase(res.headers.get("Content-Type")) !== - "application/wasm" + typeof contentType !== "string" || + StringPrototypeToLowerCase(contentType) !== "application/wasm" ) { throw new TypeError("Invalid WebAssembly content type."); } |