mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #14508 - servo:determine_request_referrer, r=jdm,frewsxcv
Rewrite determine_request_referrer() to explicitly limit it to the checks it can do. Checks for the Client value should reside in the script thread. I also noted some other issues in this code. <!-- 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/14508) <!-- Reviewable:end -->
This commit is contained in:
commit
882d5512bb
3 changed files with 40 additions and 42 deletions
|
@ -9,7 +9,6 @@ use msg::constellation_msg::PipelineId;
|
|||
use servo_url::ServoUrl;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::default::Default;
|
||||
use std::mem::swap;
|
||||
use url::{Origin as UrlOrigin};
|
||||
|
||||
/// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator)
|
||||
|
@ -308,19 +307,4 @@ impl Referrer {
|
|||
Referrer::ReferrerUrl(ref url) => Some(url)
|
||||
}
|
||||
}
|
||||
pub fn from_url(url: Option<ServoUrl>) -> Self {
|
||||
if let Some(url) = url {
|
||||
Referrer::ReferrerUrl(url)
|
||||
} else {
|
||||
Referrer::NoReferrer
|
||||
}
|
||||
}
|
||||
pub fn take(&mut self) -> Option<ServoUrl> {
|
||||
let mut new = Referrer::Client;
|
||||
swap(self, &mut new);
|
||||
match new {
|
||||
Referrer::NoReferrer | Referrer::Client => None,
|
||||
Referrer::ReferrerUrl(url) => Some(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue