fix(fetch): body.blob() sets Blob.type from Content-Type header#313
Open
godronus wants to merge 1 commit into
Open
fix(fetch): body.blob() sets Blob.type from Content-Type header#313godronus wants to merge 1 commit into
godronus wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #311.
When calling body.blob() on a Request or Response, the returned Blob was always created with an empty type, regardless of the Content-Type header on the body. This was uncovered by the WPT pass improvements in #312.
Per the Fetch spec 5.2:
▎ If type is non-null, then set object's type to the result of parse a MIME type with type's value.
This fix reads the Content-Type header from the owning request/response when constructing the Blob in parse_body, extracts the MIME type using the existing extract_mime_type helper, and passes the normalized type through Blob::normalize_type before creating the Blob object.
Changes
Testing
The fix is covered by the WPT test suite. The Consume multipart/form-data headers case-insensitively test in
fetch/api/body/formdata.any.jsnow passes.Running WPT test suite after merging Response.clone (#312) creates a new
fetch/api/body/mime-type.any.jsexpectations file. (20 PASS, 0 FAIL)