mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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.
This commit is contained in:
parent
1e3d4d272d
commit
12aa4694cb
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