mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Auto merge of #29752 - mrobinson:fix-29741-by-extending-request-builder, r=mukilan
Fix 29741 by extending request builder Extend RequestBuilder to include ResponseTainting and used said functionality to set response_tainting to `::CorsTainting` in `cors_preflight_fetch()`. --- <!-- 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 #29741 <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- 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. -->
This commit is contained in:
commit
918557ad6d
3 changed files with 11 additions and 1 deletions
|
@ -1978,6 +1978,7 @@ async fn cors_preflight_fetch(
|
||||||
.destination(request.destination.clone())
|
.destination(request.destination.clone())
|
||||||
.referrer_policy(request.referrer_policy)
|
.referrer_policy(request.referrer_policy)
|
||||||
.mode(RequestMode::CorsMode)
|
.mode(RequestMode::CorsMode)
|
||||||
|
.response_tainting(ResponseTainting::CorsTainting)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
|
|
@ -93,7 +93,7 @@ pub enum RedirectMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [Response tainting](https://fetch.spec.whatwg.org/#concept-request-response-tainting)
|
/// [Response tainting](https://fetch.spec.whatwg.org/#concept-request-response-tainting)
|
||||||
#[derive(Clone, Copy, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||||
pub enum ResponseTainting {
|
pub enum ResponseTainting {
|
||||||
Basic,
|
Basic,
|
||||||
CorsTainting,
|
CorsTainting,
|
||||||
|
@ -253,6 +253,7 @@ pub struct RequestBuilder {
|
||||||
pub parser_metadata: ParserMetadata,
|
pub parser_metadata: ParserMetadata,
|
||||||
pub initiator: Initiator,
|
pub initiator: Initiator,
|
||||||
pub https_state: HttpsState,
|
pub https_state: HttpsState,
|
||||||
|
pub response_tainting: ResponseTainting,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RequestBuilder {
|
impl RequestBuilder {
|
||||||
|
@ -282,6 +283,7 @@ impl RequestBuilder {
|
||||||
initiator: Initiator::None,
|
initiator: Initiator::None,
|
||||||
csp_list: None,
|
csp_list: None,
|
||||||
https_state: HttpsState::None,
|
https_state: HttpsState::None,
|
||||||
|
response_tainting: ResponseTainting::Basic,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,6 +377,11 @@ impl RequestBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn response_tainting(mut self, response_tainting: ResponseTainting) -> RequestBuilder {
|
||||||
|
self.response_tainting = response_tainting;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Request {
|
pub fn build(self) -> Request {
|
||||||
let mut request = Request::new(
|
let mut request = Request::new(
|
||||||
self.url.clone(),
|
self.url.clone(),
|
||||||
|
@ -407,6 +414,7 @@ impl RequestBuilder {
|
||||||
request.integrity_metadata = self.integrity_metadata;
|
request.integrity_metadata = self.integrity_metadata;
|
||||||
request.parser_metadata = self.parser_metadata;
|
request.parser_metadata = self.parser_metadata;
|
||||||
request.csp_list = self.csp_list;
|
request.csp_list = self.csp_list;
|
||||||
|
request.response_tainting = self.response_tainting;
|
||||||
request
|
request
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ fn request_init_from_request(request: NetTraitsRequest) -> RequestBuilder {
|
||||||
initiator: request.initiator,
|
initiator: request.initiator,
|
||||||
csp_list: None,
|
csp_list: None,
|
||||||
https_state: request.https_state,
|
https_state: request.https_state,
|
||||||
|
response_tainting: request.response_tainting,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue