mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #13561 - mathieuh:request-constructor, r=jdm
Make Request throw less often (fixes #13457) <!-- Please describe your changes on the following line: --> --- <!-- 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 #13457 <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13561) <!-- Reviewable:end -->
This commit is contained in:
commit
3bf81c389b
6 changed files with 15 additions and 29 deletions
|
@ -183,9 +183,8 @@ impl Request {
|
|||
!init.window.handle().is_undefined() {
|
||||
// Step 13.1
|
||||
if request.mode == NetTraitsRequestMode::Navigate {
|
||||
return Err(Error::Type(
|
||||
"Init is present and request mode is 'navigate'".to_string()));
|
||||
}
|
||||
request.mode = NetTraitsRequestMode::SameOrigin;
|
||||
}
|
||||
// Step 13.2
|
||||
request.omit_origin_header.set(false);
|
||||
// Step 13.3
|
||||
|
@ -211,17 +210,13 @@ impl Request {
|
|||
}
|
||||
// Step 14.5
|
||||
if let Ok(parsed_referrer) = parsed_referrer {
|
||||
if parsed_referrer.cannot_be_a_base() &&
|
||||
if (parsed_referrer.cannot_be_a_base() &&
|
||||
parsed_referrer.scheme() == "about" &&
|
||||
parsed_referrer.path() == "client" {
|
||||
parsed_referrer.path() == "client") ||
|
||||
parsed_referrer.origin() != origin {
|
||||
*request.referrer.borrow_mut() = NetTraitsRequestReferrer::Client;
|
||||
} else {
|
||||
// Step 14.6
|
||||
if parsed_referrer.origin() != origin {
|
||||
return Err(Error::Type(
|
||||
"RequestInit's referrer has invalid origin".to_string()));
|
||||
}
|
||||
// Step 14.7
|
||||
*request.referrer.borrow_mut() = NetTraitsRequestReferrer::ReferrerUrl(parsed_referrer);
|
||||
}
|
||||
}
|
||||
|
@ -576,7 +571,7 @@ impl RequestMethods for Request {
|
|||
let referrer = r.referrer.borrow();
|
||||
USVString(match &*referrer {
|
||||
&NetTraitsRequestReferrer::NoReferrer => String::from("no-referrer"),
|
||||
&NetTraitsRequestReferrer::Client => String::from("client"),
|
||||
&NetTraitsRequestReferrer::Client => String::from("about:client"),
|
||||
&NetTraitsRequestReferrer::ReferrerUrl(ref u) => {
|
||||
let u_c = u.clone();
|
||||
u_c.into_string()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue