Auto merge of #23090 - miller-time:nav-fetch-referrer, r=gterzian

Add referrer to navigation fetch request

<!-- Please describe your changes on the following line: -->
Implement step 13 of [following hyperlinks](https://html.spec.whatwg.org/#following-hyperlinks-2) and step 14.3 of [window open](https://html.spec.whatwg.org/#window-open-steps), as well as other referrer- and fetch-related updates.

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

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

<!-- 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/23090)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-04-25 20:21:23 -04:00 committed by GitHub
commit b73956cc37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 136 additions and 88 deletions

View file

@ -162,7 +162,7 @@ pub struct RequestBuilder {
pub use_url_credentials: bool,
pub origin: ImmutableOrigin,
// XXXManishearth these should be part of the client object
pub referrer_url: Option<ServoUrl>,
pub referrer: Option<Referrer>,
pub referrer_policy: Option<ReferrerPolicy>,
pub pipeline_id: Option<PipelineId>,
pub redirect_mode: RedirectMode,
@ -188,7 +188,7 @@ impl RequestBuilder {
credentials_mode: CredentialsMode::Omit,
use_url_credentials: false,
origin: ImmutableOrigin::new_opaque(),
referrer_url: None,
referrer: None,
referrer_policy: None,
pipeline_id: None,
redirect_mode: RedirectMode::Follow,
@ -265,8 +265,8 @@ impl RequestBuilder {
self
}
pub fn referrer_url(mut self, referrer_url: Option<ServoUrl>) -> RequestBuilder {
self.referrer_url = referrer_url;
pub fn referrer(mut self, referrer: Option<Referrer>) -> RequestBuilder {
self.referrer = referrer;
self
}
@ -313,11 +313,7 @@ impl RequestBuilder {
request.credentials_mode = self.credentials_mode;
request.use_url_credentials = self.use_url_credentials;
request.cache_mode = self.cache_mode;
request.referrer = if let Some(url) = self.referrer_url {
Referrer::ReferrerUrl(url)
} else {
Referrer::NoReferrer
};
request.referrer = self.referrer.unwrap_or(Referrer::Client);
request.referrer_policy = self.referrer_policy;
request.redirect_mode = self.redirect_mode;
let mut url_list = self.url_list;