mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
Reduce max line length from 150 to 120 characters
Part of https://github.com/servo/servo/issues/6041
This commit is contained in:
parent
7561f7b83f
commit
8e3f4bba85
141 changed files with 1161 additions and 497 deletions
|
@ -86,7 +86,8 @@ impl CookieStorage {
|
|||
// http://tools.ietf.org/html/rfc6265#section-5.4
|
||||
pub fn cookies_for_url(&mut self, url: &Url, source: CookieSource) -> Option<String> {
|
||||
let filterer = |c: &&mut Cookie| -> bool {
|
||||
info!(" === SENT COOKIE : {} {} {:?} {:?}", c.cookie.name, c.cookie.value, c.cookie.domain, c.cookie.path);
|
||||
info!(" === SENT COOKIE : {} {} {:?} {:?}",
|
||||
c.cookie.name, c.cookie.value, c.cookie.domain, c.cookie.path);
|
||||
info!(" === SENT COOKIE RESULT {}", c.appropriate_for_url(url, source));
|
||||
// Step 1
|
||||
c.appropriate_for_url(url, source)
|
||||
|
|
|
@ -53,7 +53,8 @@ pub struct CORSCacheEntry {
|
|||
}
|
||||
|
||||
impl CORSCacheEntry {
|
||||
fn new (origin:Url, url: Url, max_age: u32, credentials: bool, header_or_method: HeaderOrMethod) -> CORSCacheEntry {
|
||||
fn new(origin:Url, url: Url, max_age: u32, credentials: bool,
|
||||
header_or_method: HeaderOrMethod) -> CORSCacheEntry {
|
||||
CORSCacheEntry {
|
||||
origin: origin,
|
||||
url: url,
|
||||
|
@ -80,18 +81,22 @@ pub trait CORSCache {
|
|||
/// Remove old entries
|
||||
fn cleanup(&mut self);
|
||||
|
||||
/// Returns true if an entry with a [matching header](https://fetch.spec.whatwg.org/#concept-cache-match-header) is found
|
||||
/// Returns true if an entry with a
|
||||
/// [matching header](https://fetch.spec.whatwg.org/#concept-cache-match-header) is found
|
||||
fn match_header(&mut self, request: CacheRequestDetails, header_name: &str) -> bool;
|
||||
|
||||
/// Updates max age if an entry for a [matching header](https://fetch.spec.whatwg.org/#concept-cache-match-header) is found.
|
||||
/// Updates max age if an entry for a
|
||||
/// [matching header](https://fetch.spec.whatwg.org/#concept-cache-match-header) is found.
|
||||
///
|
||||
/// If not, it will insert an equivalent entry
|
||||
fn match_header_and_update(&mut self, request: CacheRequestDetails, header_name: &str, new_max_age: u32) -> bool;
|
||||
|
||||
/// Returns true if an entry with a [matching method](https://fetch.spec.whatwg.org/#concept-cache-match-method) is found
|
||||
/// Returns true if an entry with a
|
||||
/// [matching method](https://fetch.spec.whatwg.org/#concept-cache-match-method) is found
|
||||
fn match_method(&mut self, request: CacheRequestDetails, method: Method) -> bool;
|
||||
|
||||
/// Updates max age if an entry for [a matching method](https://fetch.spec.whatwg.org/#concept-cache-match-method) is found.
|
||||
/// Updates max age if an entry for
|
||||
/// [a matching method](https://fetch.spec.whatwg.org/#concept-cache-match-method) is found.
|
||||
///
|
||||
/// If not, it will insert an equivalent entry
|
||||
fn match_method_and_update(&mut self, request: CacheRequestDetails, method: Method, new_max_age: u32) -> bool;
|
||||
|
@ -104,7 +109,8 @@ pub trait CORSCache {
|
|||
pub struct BasicCORSCache(Vec<CORSCacheEntry>);
|
||||
|
||||
impl BasicCORSCache {
|
||||
fn find_entry_by_header<'a>(&'a mut self, request: &CacheRequestDetails, header_name: &str) -> Option<&'a mut CORSCacheEntry> {
|
||||
fn find_entry_by_header<'a>(&'a mut self, request: &CacheRequestDetails,
|
||||
header_name: &str) -> Option<&'a mut CORSCacheEntry> {
|
||||
self.cleanup();
|
||||
let BasicCORSCache(ref mut buf) = *self;
|
||||
let entry = buf.iter_mut().find(|e| e.origin.scheme == request.origin.scheme &&
|
||||
|
@ -116,7 +122,8 @@ impl BasicCORSCache {
|
|||
entry
|
||||
}
|
||||
|
||||
fn find_entry_by_method<'a>(&'a mut self, request: &CacheRequestDetails, method: Method) -> Option<&'a mut CORSCacheEntry> {
|
||||
fn find_entry_by_method<'a>(&'a mut self, request: &CacheRequestDetails,
|
||||
method: Method) -> Option<&'a mut CORSCacheEntry> {
|
||||
// we can take the method from CORSRequest itself
|
||||
self.cleanup();
|
||||
let BasicCORSCache(ref mut buf) = *self;
|
||||
|
@ -135,7 +142,8 @@ impl CORSCache for BasicCORSCache {
|
|||
#[allow(dead_code)]
|
||||
fn clear (&mut self, request: CacheRequestDetails) {
|
||||
let BasicCORSCache(buf) = self.clone();
|
||||
let new_buf: Vec<CORSCacheEntry> = buf.into_iter().filter(|e| e.origin == request.origin && request.destination == e.url).collect();
|
||||
let new_buf: Vec<CORSCacheEntry> =
|
||||
buf.into_iter().filter(|e| e.origin == request.origin && request.destination == e.url).collect();
|
||||
*self = BasicCORSCache(new_buf);
|
||||
}
|
||||
|
||||
|
@ -143,7 +151,9 @@ impl CORSCache for BasicCORSCache {
|
|||
fn cleanup(&mut self) {
|
||||
let BasicCORSCache(buf) = self.clone();
|
||||
let now = time::now().to_timespec();
|
||||
let new_buf: Vec<CORSCacheEntry> = buf.into_iter().filter(|e| now.sec > e.created.sec + e.max_age as i64).collect();
|
||||
let new_buf: Vec<CORSCacheEntry> = buf.into_iter()
|
||||
.filter(|e| now.sec > e.created.sec + e.max_age as i64)
|
||||
.collect();
|
||||
*self = BasicCORSCache(new_buf);
|
||||
}
|
||||
|
||||
|
@ -156,7 +166,8 @@ impl CORSCache for BasicCORSCache {
|
|||
Some(_) => true,
|
||||
None => {
|
||||
self.insert(CORSCacheEntry::new(request.origin, request.destination, new_max_age,
|
||||
request.credentials, HeaderOrMethod::HeaderData(header_name.to_string())));
|
||||
request.credentials,
|
||||
HeaderOrMethod::HeaderData(header_name.to_string())));
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,7 +224,8 @@ impl Request {
|
|||
}
|
||||
|
||||
/// [HTTP fetch](https://fetch.spec.whatwg.org#http-fetch)
|
||||
pub fn http_fetch(&mut self, cors_flag: bool, cors_preflight_flag: bool, authentication_fetch_flag: bool) -> Response {
|
||||
pub fn http_fetch(&mut self, cors_flag: bool, cors_preflight_flag: bool,
|
||||
authentication_fetch_flag: bool) -> Response {
|
||||
// Step 1
|
||||
let mut response: Option<Response> = None;
|
||||
// Step 2
|
||||
|
@ -333,7 +334,9 @@ impl Request {
|
|||
self.same_origin_data = false;
|
||||
// Step 10
|
||||
if self.redirect_mode == RedirectMode::Follow {
|
||||
// FIXME: Origin method of the Url crate hasn't been implemented (https://github.com/servo/rust-url/issues/54)
|
||||
// FIXME: Origin method of the Url crate hasn't been implemented
|
||||
// https://github.com/servo/rust-url/issues/54
|
||||
|
||||
// Substep 1
|
||||
// if cors_flag && location_url.origin() != self.url.origin() { self.origin = None; }
|
||||
// Substep 2
|
||||
|
@ -387,7 +390,9 @@ impl Request {
|
|||
}
|
||||
|
||||
/// [HTTP network or cache fetch](https://fetch.spec.whatwg.org#http-network-or-cache-fetch)
|
||||
pub fn http_network_or_cache_fetch(&mut self, _credentials_flag: bool, _authentication_fetch_flag: bool) -> Response {
|
||||
pub fn http_network_or_cache_fetch(&mut self,
|
||||
_credentials_flag: bool,
|
||||
_authentication_fetch_flag: bool) -> Response {
|
||||
// TODO: Implement HTTP network or cache fetch spec
|
||||
Response::network_error()
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ pub struct Response {
|
|||
pub status: Option<StatusCode>,
|
||||
pub headers: Headers,
|
||||
pub body: ResponseBody,
|
||||
/// [Internal response](https://fetch.spec.whatwg.org/#concept-internal-response), only used if the Response is a filtered response
|
||||
/// [Internal response](https://fetch.spec.whatwg.org/#concept-internal-response), only used if the Response
|
||||
/// is a filtered response
|
||||
pub internal_response: Option<Box<Response>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,8 @@ use std::boxed::FnBox;
|
|||
pub fn factory(cookies_chan: Sender<ControlMsg>, devtools_chan: Option<Sender<DevtoolsControlMsg>>)
|
||||
-> Box<FnBox(LoadData, LoadConsumer, Arc<MIMEClassifier>) + Send> {
|
||||
box move |load_data, senders, classifier| {
|
||||
spawn_named("http_loader".to_owned(), move || load(load_data, senders, classifier, cookies_chan, devtools_chan))
|
||||
spawn_named("http_loader".to_owned(),
|
||||
move || load(load_data, senders, classifier, cookies_chan, devtools_chan))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,7 +281,9 @@ reason: \"certificate verify failed\" }]))";
|
|||
Some(ref c) => {
|
||||
if c.preflight {
|
||||
// The preflight lied
|
||||
send_error(url, "Preflight fetch inconsistent with main fetch".to_string(), start_chan);
|
||||
send_error(url,
|
||||
"Preflight fetch inconsistent with main fetch".to_string(),
|
||||
start_chan);
|
||||
return;
|
||||
} else {
|
||||
// XXXManishearth There are some CORS-related steps here,
|
||||
|
@ -347,7 +350,8 @@ reason: \"certificate verify failed\" }]))";
|
|||
// Send an HttpResponse message to devtools with the corresponding request_id
|
||||
// TODO: Send this message only if load_data has a pipeline_id that is not None
|
||||
if let Some(ref chan) = devtools_chan {
|
||||
let net_event_response = NetworkEvent::HttpResponse(metadata.headers.clone(), metadata.status.clone(), None);
|
||||
let net_event_response = NetworkEvent::HttpResponse(
|
||||
metadata.headers.clone(), metadata.status.clone(), None);
|
||||
chan.send(DevtoolsControlMsg::NetworkEventMessage(request_id, net_event_response)).unwrap();
|
||||
}
|
||||
|
||||
|
|
|
@ -332,7 +332,8 @@ impl ImageCache {
|
|||
url: url,
|
||||
sender: self.progress_sender.clone(),
|
||||
};
|
||||
self.resource_task.send(ControlMsg::Load(load_data, LoadConsumer::Listener(listener))).unwrap();
|
||||
let msg = ControlMsg::Load(load_data, LoadConsumer::Listener(listener));
|
||||
self.resource_task.send(msg).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,8 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
|
|||
let supplied_type = metadata.content_type.map(|ContentType(Mime(toplevel, sublevel, _))| {
|
||||
(format!("{}", toplevel), format!("{}", sublevel))
|
||||
});
|
||||
metadata.content_type = classifier.classify(nosniff, check_for_apache_bug, &supplied_type, &partial_body).map(|(toplevel, sublevel)| {
|
||||
metadata.content_type = classifier.classify(nosniff, check_for_apache_bug, &supplied_type,
|
||||
&partial_body).map(|(toplevel, sublevel)| {
|
||||
let mime_tp: TopLevel = FromStr::from_str(&toplevel).unwrap();
|
||||
let mime_sb: SubLevel = FromStr::from_str(&sublevel).unwrap();
|
||||
ContentType(Mime(mime_tp, mime_sb, vec!()))
|
||||
|
@ -138,7 +139,8 @@ pub fn start_sending_opt(start_chan: LoadConsumer, metadata: Metadata) -> Result
|
|||
}
|
||||
|
||||
/// Create a ResourceTask
|
||||
pub fn new_resource_task(user_agent: Option<String>, devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> ResourceTask {
|
||||
pub fn new_resource_task(user_agent: Option<String>,
|
||||
devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> ResourceTask {
|
||||
let (setup_chan, setup_port) = channel();
|
||||
let setup_chan_clone = setup_chan.clone();
|
||||
spawn_named("ResourceManager".to_owned(), move || {
|
||||
|
@ -148,7 +150,8 @@ pub fn new_resource_task(user_agent: Option<String>, devtools_chan: Option<Sende
|
|||
}
|
||||
|
||||
pub fn parse_hostsfile(hostsfile_content: &str) -> Box<HashMap<String, String>> {
|
||||
let ipv4_regex = regex!(r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
|
||||
let ipv4_regex = regex!(
|
||||
r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
|
||||
let ipv6_regex = regex!(r"^([a-fA-F0-9]{0,4}[:]?){1,8}(/\d{1,3})?$");
|
||||
let mut host_table = HashMap::new();
|
||||
let lines: Vec<&str> = hostsfile_content.split('\n').collect();
|
||||
|
@ -191,8 +194,10 @@ struct ResourceManager {
|
|||
}
|
||||
|
||||
impl ResourceManager {
|
||||
fn new(from_client: Receiver<ControlMsg>, user_agent: Option<String>,
|
||||
resource_task: Sender<ControlMsg>, devtools_channel: Option<Sender<DevtoolsControlMsg>>) -> ResourceManager {
|
||||
fn new(from_client: Receiver<ControlMsg>,
|
||||
user_agent: Option<String>,
|
||||
resource_task: Sender<ControlMsg>,
|
||||
devtools_channel: Option<Sender<DevtoolsControlMsg>>) -> ResourceManager {
|
||||
ResourceManager {
|
||||
from_client: from_client,
|
||||
user_agent: user_agent,
|
||||
|
@ -250,7 +255,8 @@ impl ResourceManager {
|
|||
|
||||
let loader = match &*load_data.url.scheme {
|
||||
"file" => from_factory(file_loader::factory),
|
||||
"http" | "https" | "view-source" => http_loader::factory(self.resource_task.clone(), self.devtools_chan.clone()),
|
||||
"http" | "https" | "view-source" =>
|
||||
http_loader::factory(self.resource_task.clone(), self.devtools_chan.clone()),
|
||||
"data" => from_factory(data_loader::factory),
|
||||
"about" => from_factory(about_loader::factory),
|
||||
_ => {
|
||||
|
|
|
@ -102,7 +102,8 @@ impl StorageManager {
|
|||
|
||||
/// Sends Some(old_value) in case there was a previous value with the same key name but with different
|
||||
/// value name, otherwise sends None
|
||||
fn set_item(&mut self, sender: Sender<(bool, Option<DOMString>)>, url: Url, storage_type: StorageType, name: DOMString, value: DOMString) {
|
||||
fn set_item(&mut self, sender: Sender<(bool, Option<DOMString>)>, url: Url, storage_type: StorageType,
|
||||
name: DOMString, value: DOMString) {
|
||||
let origin = self.get_origin_as_string(url);
|
||||
let data = self.select_data_mut(storage_type);
|
||||
if !data.contains_key(&origin) {
|
||||
|
@ -130,7 +131,8 @@ impl StorageManager {
|
|||
}
|
||||
|
||||
/// Sends Some(old_value) in case there was a previous value with the key name, otherwise sends None
|
||||
fn remove_item(&mut self, sender: Sender<Option<DOMString>>, url: Url, storage_type: StorageType, name: DOMString) {
|
||||
fn remove_item(&mut self, sender: Sender<Option<DOMString>>, url: Url, storage_type: StorageType,
|
||||
name: DOMString) {
|
||||
let origin = self.get_origin_as_string(url);
|
||||
let data = self.select_data_mut(storage_type);
|
||||
let old_value = data.get_mut(&origin).and_then(|entry| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue