Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSet response mime_type based on Content-Type #24669
Conversation
highfive
commented
Nov 6, 2019
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @jdm (or someone else) soon. |
highfive
commented
Nov 6, 2019
|
Heads up! This PR modifies the following files:
|
|
Sorry for the review delay, and thanks for the detailed explanation! I agree that this seems like a sensible way to fix the issue. |
|
|
Set response mime_type based on Content-Type <!-- Please describe your changes on the following line: --> Set the response's `mime_type` based on its `Content-Type` header whenever `Response::set_headers` is called. This ensures that `mime_type` is always consistent with `Content-Type`. The other reason for going with this approach is it relies on `extract_mime_type`: https://github.com/servo/servo/blob/afbcbf75eaa63ff0eec8fd3858e9155eb8dbadaa/components/script/dom/headers.rs#L260-L261 Besides the consistency argument, I also expect that we'll update the `extract_mime_type` method to conform with its specification. Another option I explored was adding a `set_mime_type` member to `Response` and calling that with the mime type from `Metadata::content_type` in `FetchResponseListener::process_response`. I decided against this since it expanded the interface of `Response` and didn't have the same benefits of the first option. Fixes #24628. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #24628. <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
That's interesting... |
|
https://searchfox.org/mozilla-central/source/testing/web-platform/tests/fetch/corb/script-html-via-cross-origin-blob-url.sub.html loads https://searchfox.org/mozilla-central/source/testing/web-platform/tests/fetch/corb/resources/subframe-that-posts-html-containing-blob-url-to-parent.html which does use fetch and Response, so we should dig into what's changed there. |
|
It looks like setting the mime type is allowing this test (
Now that the proper mime type is set, the test progresses but errors out later. It looks like Servo is allowing html-correctly-labeled.html to be added to the document as a script element. The trouble is that this is content actually an HTML page and not javascript, so Servo chokes on the first character of Servo should actually block this content from being loaded, but I suspect that we haven't implemented the appropriate CORB checks yet. One option to move things forward would be to update |
|
Aha, thanks! Your analysis makes complete sense; let's update the expected result since we haven't implemented the CORB specification yet. |
|
@bors-servo r+ |
|
|
Set response mime_type based on Content-Type <!-- Please describe your changes on the following line: --> Set the response's `mime_type` based on its `Content-Type` header whenever `Response::set_headers` is called. This ensures that `mime_type` is always consistent with `Content-Type`. The other reason for going with this approach is it relies on `extract_mime_type`: https://github.com/servo/servo/blob/afbcbf75eaa63ff0eec8fd3858e9155eb8dbadaa/components/script/dom/headers.rs#L260-L261 Besides the consistency argument, I also expect that we'll update the `extract_mime_type` method to conform with its specification. Another option I explored was adding a `set_mime_type` member to `Response` and calling that with the mime type from `Metadata::content_type` in `FetchResponseListener::process_response`. I decided against this since it expanded the interface of `Response` and didn't have the same benefits of the first option. Fixes #24628. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #24628. <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
|
@bors-servo retry |
Set response mime_type based on Content-Type <!-- Please describe your changes on the following line: --> Set the response's `mime_type` based on its `Content-Type` header whenever `Response::set_headers` is called. This ensures that `mime_type` is always consistent with `Content-Type`. The other reason for going with this approach is it relies on `extract_mime_type`: https://github.com/servo/servo/blob/afbcbf75eaa63ff0eec8fd3858e9155eb8dbadaa/components/script/dom/headers.rs#L260-L261 Besides the consistency argument, I also expect that we'll update the `extract_mime_type` method to conform with its specification. Another option I explored was adding a `set_mime_type` member to `Response` and calling that with the mime type from `Metadata::content_type` in `FetchResponseListener::process_response`. I decided against this since it expanded the interface of `Response` and didn't have the same benefits of the first option. Fixes #24628. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #24628. <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|

glowe commentedNov 6, 2019
Set the response's
mime_typebased on itsContent-Typeheader wheneverResponse::set_headersis called. This ensures thatmime_typeis always consistent withContent-Type. The other reason for going with this approach is it relies onextract_mime_type:servo/components/script/dom/headers.rs
Lines 260 to 261 in afbcbf7
Besides the consistency argument, I also expect that we'll update the
extract_mime_typemethod to conform with its specification.Another option I explored was adding a
set_mime_typemember toResponseand calling that with the mime type fromMetadata::content_typeinFetchResponseListener::process_response. I decided against this since it expanded the interface ofResponseand didn't have the same benefits of the first option.Fixes #24628.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors