mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Rustfmt has changed its default style :/
This commit is contained in:
parent
82fc6d9f49
commit
be69f9c3e6
207 changed files with 1200 additions and 1339 deletions
|
@ -233,9 +233,10 @@ fn evict_one_cookie(is_secure_cookie: bool, cookies: &mut Vec<Cookie>) -> bool {
|
|||
fn get_oldest_accessed(is_secure_cookie: bool, cookies: &mut Vec<Cookie>) -> Option<(usize, Tm)> {
|
||||
let mut oldest_accessed: Option<(usize, Tm)> = None;
|
||||
for (i, c) in cookies.iter().enumerate() {
|
||||
if (c.cookie.secure().unwrap_or(false) == is_secure_cookie) && oldest_accessed
|
||||
.as_ref()
|
||||
.map_or(true, |a| c.last_access < a.1)
|
||||
if (c.cookie.secure().unwrap_or(false) == is_secure_cookie) &&
|
||||
oldest_accessed
|
||||
.as_ref()
|
||||
.map_or(true, |a| c.last_access < a.1)
|
||||
{
|
||||
oldest_accessed = Some((i, c.last_access));
|
||||
}
|
||||
|
|
|
@ -253,10 +253,10 @@ pub fn main_fetch(
|
|||
Response::network_error(NetworkError::Internal("Non-http scheme".into()))
|
||||
} else if request.use_cors_preflight ||
|
||||
(request.unsafe_request &&
|
||||
(!is_cors_safelisted_method(&request.method) || request
|
||||
.headers
|
||||
.iter()
|
||||
.any(|(name, value)| !is_cors_safelisted_request_header(&name, &value))))
|
||||
(!is_cors_safelisted_method(&request.method) ||
|
||||
request.headers.iter().any(|(name, value)| {
|
||||
!is_cors_safelisted_request_header(&name, &value)
|
||||
})))
|
||||
{
|
||||
// Substep 1.
|
||||
request.response_tainting = ResponseTainting::CorsTainting;
|
||||
|
@ -372,10 +372,12 @@ pub fn main_fetch(
|
|||
// in the previous step.
|
||||
let not_network_error = !response_is_network_error && !internal_response.is_network_error();
|
||||
if not_network_error &&
|
||||
(is_null_body_status(&internal_response.status) || match request.method {
|
||||
Method::HEAD | Method::CONNECT => true,
|
||||
_ => false,
|
||||
}) {
|
||||
(is_null_body_status(&internal_response.status) ||
|
||||
match request.method {
|
||||
Method::HEAD | Method::CONNECT => true,
|
||||
_ => false,
|
||||
})
|
||||
{
|
||||
// when Fetch is used only asynchronously, we will need to make sure
|
||||
// that nothing tries to write to the body at this point
|
||||
let mut body = internal_response.body.lock().unwrap();
|
||||
|
@ -785,7 +787,8 @@ pub fn should_be_blocked_due_to_nosniff(
|
|||
.get("x-content-type-options")
|
||||
.map_or(true, |val| {
|
||||
val.to_str().unwrap_or("").to_lowercase() != "nosniff"
|
||||
}) {
|
||||
})
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -850,12 +853,13 @@ fn should_be_blocked_due_to_mime_type(
|
|||
};
|
||||
|
||||
// Step 2-3
|
||||
destination.is_script_like() && match mime_type.type_() {
|
||||
mime::AUDIO | mime::VIDEO | mime::IMAGE => true,
|
||||
mime::TEXT if mime_type.subtype() == mime::CSV => true,
|
||||
// Step 4
|
||||
_ => false,
|
||||
}
|
||||
destination.is_script_like() &&
|
||||
match mime_type.type_() {
|
||||
mime::AUDIO | mime::VIDEO | mime::IMAGE => true,
|
||||
mime::TEXT if mime_type.subtype() == mime::CSV => true,
|
||||
// Step 4
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://fetch.spec.whatwg.org/#block-bad-port>
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use brotli::Decompressor;
|
||||
use bytes::Bytes;
|
||||
use crate::connector::{create_http_client, Connector, WrappedBody, BUF_SIZE};
|
||||
use crate::cookie;
|
||||
use crate::cookie_storage::CookieStorage;
|
||||
|
@ -15,6 +13,8 @@ use crate::fetch::methods::{Data, DoneChannel, FetchContext, Target};
|
|||
use crate::hsts::HstsList;
|
||||
use crate::http_cache::HttpCache;
|
||||
use crate::resource_thread::AuthCache;
|
||||
use brotli::Decompressor;
|
||||
use bytes::Bytes;
|
||||
use crossbeam_channel::{unbounded, Sender};
|
||||
use devtools_traits::{
|
||||
ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpRequest as DevtoolsHttpRequest,
|
||||
|
@ -684,13 +684,13 @@ pub fn http_redirect_fetch(
|
|||
Some(Err(err)) => {
|
||||
return Response::network_error(NetworkError::Internal(
|
||||
"Location URL parse failure: ".to_owned() + &err,
|
||||
))
|
||||
));
|
||||
},
|
||||
// Step 4
|
||||
Some(Ok(ref url)) if !matches!(url.scheme(), "http" | "https") => {
|
||||
return Response::network_error(NetworkError::Internal(
|
||||
"Location URL not an HTTP(S) scheme".into(),
|
||||
))
|
||||
));
|
||||
},
|
||||
Some(Ok(url)) => url,
|
||||
};
|
||||
|
@ -749,7 +749,8 @@ pub fn http_redirect_fetch(
|
|||
((*code == StatusCode::MOVED_PERMANENTLY || *code == StatusCode::FOUND) &&
|
||||
request.method == Method::POST) ||
|
||||
(*code == StatusCode::SEE_OTHER && request.method != Method::HEAD)
|
||||
}) {
|
||||
})
|
||||
{
|
||||
request.method = Method::GET;
|
||||
request.body = None;
|
||||
}
|
||||
|
@ -1069,10 +1070,11 @@ fn http_network_or_cache_fetch(
|
|||
}
|
||||
}
|
||||
// Substep 4
|
||||
if revalidating_flag && forward_response
|
||||
.status
|
||||
.as_ref()
|
||||
.map_or(false, |s| s.0 == StatusCode::NOT_MODIFIED)
|
||||
if revalidating_flag &&
|
||||
forward_response
|
||||
.status
|
||||
.as_ref()
|
||||
.map_or(false, |s| s.0 == StatusCode::NOT_MODIFIED)
|
||||
{
|
||||
if let Ok(mut http_cache) = context.state.http_cache.write() {
|
||||
response = http_cache.refresh(&http_request, forward_response.clone(), done_chan);
|
||||
|
@ -1416,10 +1418,11 @@ fn cors_preflight_fetch(
|
|||
let response = http_network_or_cache_fetch(&mut preflight, false, false, &mut None, context);
|
||||
|
||||
// Step 6
|
||||
if cors_check(&request, &response).is_ok() && response
|
||||
.status
|
||||
.as_ref()
|
||||
.map_or(false, |(status, _)| status.is_success())
|
||||
if cors_check(&request, &response).is_ok() &&
|
||||
response
|
||||
.status
|
||||
.as_ref()
|
||||
.map_or(false, |(status, _)| status.is_success())
|
||||
{
|
||||
// Substep 1, 2
|
||||
let mut methods = if response
|
||||
|
@ -1432,7 +1435,7 @@ fn cors_preflight_fetch(
|
|||
None => {
|
||||
return Response::network_error(NetworkError::Internal(
|
||||
"CORS ACAM check failed".into(),
|
||||
))
|
||||
));
|
||||
},
|
||||
}
|
||||
} else {
|
||||
|
@ -1450,7 +1453,7 @@ fn cors_preflight_fetch(
|
|||
None => {
|
||||
return Response::network_error(NetworkError::Internal(
|
||||
"CORS ACAH check failed".into(),
|
||||
))
|
||||
));
|
||||
},
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -404,9 +404,10 @@ impl Mp4Matcher {
|
|||
}
|
||||
|
||||
let mp4 = [0x6D, 0x70, 0x34];
|
||||
data[8..].starts_with(&mp4) || data[16..box_size]
|
||||
.chunks(4)
|
||||
.any(|chunk| chunk.starts_with(&mp4))
|
||||
data[8..].starts_with(&mp4) ||
|
||||
data[16..box_size]
|
||||
.chunks(4)
|
||||
.any(|chunk| chunk.starts_with(&mp4))
|
||||
}
|
||||
}
|
||||
impl MIMEChecker for Mp4Matcher {
|
||||
|
|
|
@ -260,25 +260,19 @@ fn test_cors_preflight_fetch() {
|
|||
let handler = move |request: HyperRequest<Body>, response: &mut HyperResponse<Body>| {
|
||||
if request.method() == Method::OPTIONS && state.clone().fetch_add(1, Ordering::SeqCst) == 0
|
||||
{
|
||||
assert!(
|
||||
request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD)
|
||||
);
|
||||
assert!(
|
||||
!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS)
|
||||
);
|
||||
assert!(
|
||||
!request
|
||||
.headers()
|
||||
.get(header::REFERER)
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.contains("a.html")
|
||||
);
|
||||
assert!(request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD));
|
||||
assert!(!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS));
|
||||
assert!(!request
|
||||
.headers()
|
||||
.get(header::REFERER)
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.contains("a.html"));
|
||||
response
|
||||
.headers_mut()
|
||||
.typed_insert(AccessControlAllowOrigin::ANY);
|
||||
|
@ -324,16 +318,12 @@ fn test_cors_preflight_cache_fetch() {
|
|||
let handler = move |request: HyperRequest<Body>, response: &mut HyperResponse<Body>| {
|
||||
if request.method() == Method::OPTIONS && state.clone().fetch_add(1, Ordering::SeqCst) == 0
|
||||
{
|
||||
assert!(
|
||||
request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD)
|
||||
);
|
||||
assert!(
|
||||
!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS)
|
||||
);
|
||||
assert!(request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD));
|
||||
assert!(!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS));
|
||||
response
|
||||
.headers_mut()
|
||||
.typed_insert(AccessControlAllowOrigin::ANY);
|
||||
|
@ -393,16 +383,12 @@ fn test_cors_preflight_fetch_network_error() {
|
|||
let handler = move |request: HyperRequest<Body>, response: &mut HyperResponse<Body>| {
|
||||
if request.method() == Method::OPTIONS && state.clone().fetch_add(1, Ordering::SeqCst) == 0
|
||||
{
|
||||
assert!(
|
||||
request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD)
|
||||
);
|
||||
assert!(
|
||||
!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS)
|
||||
);
|
||||
assert!(request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD));
|
||||
assert!(!request
|
||||
.headers()
|
||||
.contains_key(header::ACCESS_CONTROL_REQUEST_HEADERS));
|
||||
response
|
||||
.headers_mut()
|
||||
.typed_insert(AccessControlAllowOrigin::ANY);
|
||||
|
@ -461,11 +447,9 @@ fn test_fetch_response_is_basic_filtered() {
|
|||
|
||||
let headers = fetch_response.headers;
|
||||
assert!(!headers.contains_key(header::SET_COOKIE));
|
||||
assert!(
|
||||
headers
|
||||
.get(HeaderName::from_static("set-cookie2"))
|
||||
.is_none()
|
||||
);
|
||||
assert!(headers
|
||||
.get(HeaderName::from_static("set-cookie2"))
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -535,11 +519,9 @@ fn test_fetch_response_is_cors_filtered() {
|
|||
|
||||
assert!(!headers.contains_key(header::ACCESS_CONTROL_ALLOW_ORIGIN));
|
||||
assert!(!headers.contains_key(header::SET_COOKIE));
|
||||
assert!(
|
||||
headers
|
||||
.get(HeaderName::from_static("set-cookie2"))
|
||||
.is_none()
|
||||
);
|
||||
assert!(headers
|
||||
.get(HeaderName::from_static("set-cookie2"))
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -102,14 +102,12 @@ fn test_push_entry_with_0_max_age_evicts_entry_from_list() {
|
|||
let mut entries_map = HashMap::new();
|
||||
entries_map.insert(
|
||||
"mozilla.org".to_owned(),
|
||||
vec![
|
||||
HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
Some(500000u64),
|
||||
)
|
||||
.unwrap(),
|
||||
],
|
||||
vec![HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
Some(500000u64),
|
||||
)
|
||||
.unwrap()],
|
||||
);
|
||||
let mut list = HstsList {
|
||||
entries_map: entries_map,
|
||||
|
@ -180,14 +178,12 @@ fn test_push_entry_to_hsts_list_should_not_create_duplicate_entry() {
|
|||
let mut entries_map = HashMap::new();
|
||||
entries_map.insert(
|
||||
"mozilla.org".to_owned(),
|
||||
vec![
|
||||
HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap(),
|
||||
],
|
||||
vec![HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap()],
|
||||
);
|
||||
let mut list = HstsList {
|
||||
entries_map: entries_map,
|
||||
|
@ -286,14 +282,12 @@ fn test_hsts_list_with_exact_domain_entry_is_is_host_secure() {
|
|||
let mut entries_map = HashMap::new();
|
||||
entries_map.insert(
|
||||
"mozilla.org".to_owned(),
|
||||
vec![
|
||||
HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap(),
|
||||
],
|
||||
vec![HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap()],
|
||||
);
|
||||
|
||||
let hsts_list = HstsList {
|
||||
|
@ -322,14 +316,12 @@ fn test_hsts_list_with_subdomain_when_include_subdomains_is_false_is_not_is_host
|
|||
let mut entries_map = HashMap::new();
|
||||
entries_map.insert(
|
||||
"mozilla.org".to_owned(),
|
||||
vec![
|
||||
HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap(),
|
||||
],
|
||||
vec![HstsEntry::new(
|
||||
"mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded,
|
||||
None,
|
||||
)
|
||||
.unwrap()],
|
||||
);
|
||||
let hsts_list = HstsList {
|
||||
entries_map: entries_map,
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cookie_rs::Cookie as CookiePair;
|
||||
use crate::fetch;
|
||||
use crate::fetch_with_context;
|
||||
use crate::make_server;
|
||||
use crate::new_fetch_context;
|
||||
use cookie_rs::Cookie as CookiePair;
|
||||
use crossbeam_channel::{unbounded, Receiver};
|
||||
use devtools_traits::HttpRequest as DevtoolsHttpRequest;
|
||||
use devtools_traits::HttpResponse as DevtoolsHttpResponse;
|
||||
|
@ -144,15 +144,13 @@ fn test_check_default_headers_loaded_in_every_request() {
|
|||
..RequestInit::default()
|
||||
});
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
// Testing for method.POST
|
||||
let mut post_headers = headers.clone();
|
||||
|
@ -174,15 +172,13 @@ fn test_check_default_headers_loaded_in_every_request() {
|
|||
..RequestInit::default()
|
||||
});
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
}
|
||||
|
@ -208,15 +204,13 @@ fn test_load_when_request_is_not_get_or_head_and_there_is_no_body_content_length
|
|||
..RequestInit::default()
|
||||
});
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
}
|
||||
|
@ -245,15 +239,13 @@ fn test_request_and_response_data_with_network_messages() {
|
|||
});
|
||||
let (devtools_chan, devtools_port) = unbounded();
|
||||
let response = fetch(&mut request, Some(devtools_chan));
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
|
||||
|
@ -346,15 +338,13 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() {
|
|||
});
|
||||
let (devtools_chan, devtools_port) = unbounded();
|
||||
let response = fetch(&mut request, Some(devtools_chan));
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
|
||||
|
@ -592,15 +582,13 @@ fn test_load_doesnt_add_host_to_sts_list_when_url_is_http_even_if_sts_headers_ar
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
assert_eq!(
|
||||
context
|
||||
.state
|
||||
|
@ -641,15 +629,13 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
assert_cookie_for_domain(
|
||||
&context.state.cookie_jar,
|
||||
|
@ -696,15 +682,13 @@ fn test_load_sets_requests_cookies_header_for_url_by_getting_cookies_from_the_re
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -745,15 +729,13 @@ fn test_load_sends_cookie_if_nonhttp() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -785,15 +767,13 @@ fn test_cookie_set_with_httponly_should_not_be_available_using_getcookiesforurl(
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
assert_cookie_for_domain(
|
||||
&context.state.cookie_jar,
|
||||
|
@ -801,11 +781,9 @@ fn test_cookie_set_with_httponly_should_not_be_available_using_getcookiesforurl(
|
|||
Some("mozillaIs=theBest"),
|
||||
);
|
||||
let mut cookie_jar = context.state.cookie_jar.write().unwrap();
|
||||
assert!(
|
||||
cookie_jar
|
||||
.cookies_for_url(&url, CookieSource::NonHTTP)
|
||||
.is_none()
|
||||
);
|
||||
assert!(cookie_jar
|
||||
.cookies_for_url(&url, CookieSource::NonHTTP)
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -837,15 +815,13 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
assert_cookie_for_domain(&context.state.cookie_jar, url.as_str(), None);
|
||||
}
|
||||
|
@ -876,15 +852,13 @@ fn test_load_sets_content_length_to_length_of_request_body() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -918,15 +892,13 @@ fn test_load_uses_explicit_accept_from_headers_in_load_data() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -957,15 +929,13 @@ fn test_load_sets_default_accept_to_html_xhtml_xml_and_then_anything_else() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -999,15 +969,13 @@ fn test_load_uses_explicit_accept_encoding_from_load_data_headers() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1038,15 +1006,13 @@ fn test_load_sets_default_accept_encoding_to_gzip_and_deflate() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1374,15 +1340,13 @@ fn test_if_auth_creds_not_in_url_but_in_cache_it_sets_it() {
|
|||
|
||||
let _ = server.close();
|
||||
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1439,15 +1403,13 @@ fn test_origin_set() {
|
|||
..RequestInit::default()
|
||||
});
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let origin_url = ServoUrl::parse("http://example.com").unwrap();
|
||||
origin =
|
||||
|
@ -1464,15 +1426,13 @@ fn test_origin_set() {
|
|||
|
||||
*origin_header_clone.lock().unwrap() = Some(origin.clone());
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
// Test Origin header is not set on method Head
|
||||
let mut request = Request::from_init(RequestInit {
|
||||
|
@ -1485,15 +1445,13 @@ fn test_origin_set() {
|
|||
|
||||
*origin_header_clone.lock().unwrap() = None;
|
||||
let response = fetch(&mut request, None);
|
||||
assert!(
|
||||
response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success()
|
||||
);
|
||||
assert!(response
|
||||
.internal_response
|
||||
.unwrap()
|
||||
.status
|
||||
.unwrap()
|
||||
.0
|
||||
.is_success());
|
||||
|
||||
let _ = server.close();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue