Skip to content

Commit

Permalink
Auto merge of #13561 - mathieuh:request-constructor, r=<try>
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
bors-servo committed Oct 3, 2016
2 parents 522734d + 272f38e commit 44df984
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions components/script/dom/request.rs
Expand Up @@ -181,9 +181,8 @@ impl Request {
!init.window.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
Expand Down Expand Up @@ -211,15 +210,11 @@ impl Request {
if let Ok(parsed_referrer) = parsed_referrer {
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);
}
}
Expand Down

0 comments on commit 44df984

Please sign in to comment.