mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
@ -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>>,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue