diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 305eb1bdf83..b357edae05e 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -312,6 +312,8 @@ fn main_fetch(request: Rc, cache: &mut CORSCache, cors_flag: bool, if let Some(ref mut target) = *target { target.process_response_chunk(vec.clone()); } + } else { + assert!(*response.body.lock().unwrap() == ResponseBody::Empty) } // overloaded similarly to process_response @@ -357,6 +359,8 @@ fn main_fetch(request: Rc, cache: &mut CORSCache, cors_flag: bool, // obtained synchronously via basic_fetch for data/file/about/etc // We should still send the body across as a chunk target.process_response_chunk(vec.clone()); + } else { + assert!(*response.body.lock().unwrap() == ResponseBody::Empty) } } @@ -820,8 +824,10 @@ fn http_network_or_cache_fetch(request: Rc, if !http_request.use_url_credentials || !has_credentials(¤t_url) { authorization_value = Some(basic); } - } else if authentication_fetch_flag { - // Substep 5 + } + + // Substep 5 + if authentication_fetch_flag && authorization_value.is_none() { if has_credentials(¤t_url) { authorization_value = Some(Basic { username: current_url.username().to_owned(), diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 1123af628ab..2855e38bf45 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -435,9 +435,9 @@ fn strip_url(mut referrer_url: Url, origin_only: bool) -> Option { /// https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer pub fn determine_request_referrer(headers: &mut Headers, - referrer_policy: Option, - referrer_url: Option, - url: Url) -> Option { + referrer_policy: Option, + referrer_url: Option, + url: Url) -> Option { //TODO - algorithm step 2 not addressed assert!(!headers.has::()); if let Some(ref_url) = referrer_url { diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs index 4c7f4081f77..1fbcdabe868 100644 --- a/components/net_traits/request.rs +++ b/components/net_traits/request.rs @@ -117,7 +117,7 @@ pub struct RequestInit { pub unsafe_request: bool, pub same_origin_data: bool, pub body: Option>, - // TODO: cleint object + // TODO: client object pub destination: Destination, pub synchronous: bool, pub mode: RequestMode, @@ -214,7 +214,9 @@ impl Request { } pub fn from_init(init: RequestInit) -> Request { - let mut req = Request::new(init.url, None, false); + let mut req = Request::new(init.url, + Some(Origin::Origin(init.origin.origin())), + false); *req.method.borrow_mut() = init.method; *req.headers.borrow_mut() = init.headers; req.unsafe_request = init.unsafe_request; @@ -226,7 +228,6 @@ impl Request { req.use_cors_preflight = init.use_cors_preflight; req.credentials_mode = init.credentials_mode; req.use_url_credentials = init.use_url_credentials; - *req.origin.borrow_mut() = Origin::Origin(init.origin.origin()); *req.referer.borrow_mut() = if let Some(url) = init.referer_url { Referer::RefererUrl(url) } else { diff --git a/components/net_traits/response.rs b/components/net_traits/response.rs index e20b7b1dbeb..ab1d5b1c8f5 100644 --- a/components/net_traits/response.rs +++ b/components/net_traits/response.rs @@ -226,9 +226,13 @@ impl Response { let mut metadata = if let Some(ref url) = self.url { Metadata::default(url.clone()) } else { - return Err(NetworkError::Internal("No url found".to_string())); + return Err(NetworkError::Internal("No url found in response".to_string())); }; + if self.is_network_error() { + return Err(NetworkError::Internal("Cannot extract metadata from network error".to_string())); + } + metadata.set_content_type(match self.headers.get() { Some(&ContentType(ref mime)) => Some(mime), None => None diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 056bb6f72bb..95f1044fd36 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -60,7 +60,6 @@ smallvec = "0.1" string_cache = {version = "0.2.18", features = ["heap_size", "unstable"]} style = {path = "../style"} time = "0.1.12" -unicase = "1.0" url = {version = "1.0.0", features = ["heap_size", "query_encoding"]} util = {path = "../util"} uuid = {version = "0.2", features = ["v4"]} diff --git a/components/script/cors.rs b/components/script/cors.rs deleted file mode 100644 index f9d0bbbd264..00000000000 --- a/components/script/cors.rs +++ /dev/null @@ -1,490 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! A partial implementation of CORS -//! For now this library is XHR-specific. -//! For stuff involving ``, `