Skip to content
Permalink
Browse files

Auto merge of #24379 - PeaceRebel:dom_response_check_opaque_filter, r…

…=<try>

Dom response check opaque filter

<!-- Please describe your changes on the following line: -->
Added setters for url_list, status, and body in `Response`. Response members are set for [Network Error](https://fetch.spec.whatwg.org/#concept-network-error), [Opaque](https://fetch.spec.whatwg.org/#concept-filtered-response-opaque) and [Opaque-redirect](https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect) responses.

---
<!-- 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 #24372 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR
- [X] These changes do not require tests because running tests specified in the #24372 doesn't report any error.

<!-- 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. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24379)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Oct 9, 2019
2 parents b34fc13 + d60de1a commit 31ddecf09806d4e1548e90993de89715534dd906
@@ -395,6 +395,7 @@ fn serialize_without_fragment(url: &ServoUrl) -> &str {
impl Response {
pub fn set_type(&self, new_response_type: DOMResponseType) {
*self.response_type.borrow_mut() = new_response_type;
self.set_response_members_by_type(new_response_type);
}

pub fn set_headers(&self, option_hyper_headers: Option<Serde<HyperHeaders>>) {
@@ -412,6 +413,33 @@ impl Response {
*self.url.borrow_mut() = Some(final_url);
}

fn set_response_members_by_type(&self, response_type: DOMResponseType) {
match response_type {
DOMResponseType::Error => {
*self.status.borrow_mut() = None;
self.set_raw_status(None);
self.set_headers(None);
*self.body.borrow_mut() = NetTraitsResponseBody::Done(vec![]);
},
DOMResponseType::Opaque => {
*self.url_list.borrow_mut() = vec![];
*self.status.borrow_mut() = None;
self.set_raw_status(None);
self.set_headers(None);
*self.body.borrow_mut() = NetTraitsResponseBody::Done(vec![]);
},
DOMResponseType::Opaqueredirect => {
*self.status.borrow_mut() = None;
self.set_raw_status(None);
self.set_headers(None);
*self.body.borrow_mut() = NetTraitsResponseBody::Done(vec![]);
},
DOMResponseType::Default => {},
DOMResponseType::Basic => {},
DOMResponseType::Cors => {},
}
}

#[allow(unrooted_must_root)]
pub fn finish(&self, body: Vec<u8>) {
*self.body.borrow_mut() = NetTraitsResponseBody::Done(body);
@@ -239,14 +239,16 @@ impl FetchResponseListener for FetchContext {
fill_headers_with_metadata(self.response_object.root(), m);
self.response_object.root().set_type(DOMResponseType::Cors);
},
FilteredMetadata::Opaque => self
.response_object
.root()
.set_type(DOMResponseType::Opaque),
FilteredMetadata::OpaqueRedirect => self
.response_object
.root()
.set_type(DOMResponseType::Opaqueredirect),
FilteredMetadata::Opaque => {
self.response_object
.root()
.set_type(DOMResponseType::Opaque);
},
FilteredMetadata::OpaqueRedirect => {
self.response_object
.root()
.set_type(DOMResponseType::Opaqueredirect);
},
},
},
}
@@ -19,9 +19,6 @@
[CORS invalid integrity]
expected: FAIL

[Empty string integrity for opaque response]
expected: FAIL

[SHA-* integrity for opaque response]
expected: FAIL

@@ -39,9 +36,6 @@
[CORS invalid integrity]
expected: FAIL

[Empty string integrity for opaque response]
expected: FAIL

[SHA-* integrity for opaque response]
expected: FAIL

This file was deleted.

0 comments on commit 31ddecf

Please sign in to comment.
You can’t perform that action at this time.