Auto merge of #11468 - rebstar6:refPol4, r=nox

Implement meta referrer policy delivery (3)

<!-- 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 #10311 (github issue number if applicable).

<!-- Either: -->
- [X] 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11468)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-02 21:51:10 -05:00
commit 530b5a649e
56 changed files with 136 additions and 263 deletions

View file

@ -596,7 +596,8 @@ pub fn modify_request_headers(headers: &mut Headers,
cookie_jar: &Arc<RwLock<CookieStorage>>,
auth_cache: &Arc<RwLock<AuthCache>>,
load_data: &LoadData,
block_cookies: bool) {
block_cookies: bool,
referrer_url: &mut Option<Url>) {
// Ensure that the host header is set from the original url
let host = Host {
hostname: url.host_str().unwrap().to_owned(),
@ -617,10 +618,12 @@ pub fn modify_request_headers(headers: &mut Headers,
set_default_accept(headers);
set_default_accept_encoding(headers);
if let Some(referer_val) = determine_request_referrer(headers,
load_data.referrer_policy.clone(),
load_data.referrer_url.clone(),
url.clone()) {
*referrer_url = determine_request_referrer(headers,
load_data.referrer_policy.clone(),
referrer_url.clone(),
url.clone());
if let Some(referer_val) = referrer_url.clone() {
headers.set(Referer(referer_val.into_string()));
}
@ -808,6 +811,8 @@ pub fn load<A, B>(load_data: &LoadData,
let mut doc_url = load_data.url.clone();
let mut redirected_to = HashSet::new();
let mut method = load_data.method.clone();
// URL of referrer - to be updated with redirects
let mut referrer_url = load_data.referrer_url.clone();
let mut new_auth_header: Option<Authorization<Basic>> = None;
@ -901,7 +906,8 @@ pub fn load<A, B>(load_data: &LoadData,
modify_request_headers(&mut request_headers, &doc_url,
&user_agent, &http_state.cookie_jar,
&http_state.auth_cache, &load_data, block_cookies);
&http_state.auth_cache, &load_data,
block_cookies, &mut referrer_url);
//if there is a new auth header then set the request headers with it
if let Some(ref auth_header) = new_auth_header {