aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/response.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-11-18 17:31:47 -0500
committerGitHub <noreply@github.com>2019-11-18 17:31:47 -0500
commit18ab860f4cac5520306b09f8ab6b0e2f1539a2cf (patch)
tree50f78775f77ee7018335718df691666bbcc4f950 /components/script/dom/response.rs
parent2a5b7be557001ef118f4f1aa71f358f8a4f3d171 (diff)
parente73528e5fc834a5fe37fdcefb3b87f1b87a23241 (diff)
downloadservo-18ab860f4cac5520306b09f8ab6b0e2f1539a2cf.tar.gz
servo-18ab860f4cac5520306b09f8ab6b0e2f1539a2cf.zip
Auto merge of #24669 - glowe:issue-24628/set-mime-type, r=jdm
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. -->
Diffstat (limited to 'components/script/dom/response.rs')
-rw-r--r--components/script/dom/response.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs
index d618c9823e4..184e5ff8888 100644
--- a/components/script/dom/response.rs
+++ b/components/script/dom/response.rs
@@ -403,6 +403,7 @@ impl Response {
Some(hyper_headers) => hyper_headers.into_inner(),
None => HyperHeaders::new(),
});
+ *self.mime_type.borrow_mut() = self.Headers().extract_mime_type();
}
pub fn set_raw_status(&self, status: Option<(u16, Vec<u8>)>) {