mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Format remaining files
This commit is contained in:
parent
bf47f90da6
commit
cb07debcb6
252 changed files with 5944 additions and 3744 deletions
|
@ -236,10 +236,9 @@ 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));
|
||||
}
|
||||
|
|
|
@ -254,10 +254,11 @@ 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;
|
||||
// Substep 2.
|
||||
|
@ -372,11 +373,10 @@ 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();
|
||||
|
@ -791,13 +791,12 @@ 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>
|
||||
|
|
|
@ -506,12 +506,10 @@ pub fn http_fetch(
|
|||
}
|
||||
|
||||
// Substep 2
|
||||
if response.is_none() &&
|
||||
request.is_subresource_request() &&
|
||||
match request.origin {
|
||||
Origin::Origin(ref origin) => *origin == request.url().origin(),
|
||||
_ => false,
|
||||
} {
|
||||
if response.is_none() && request.is_subresource_request() && match request.origin {
|
||||
Origin::Origin(ref origin) => *origin == request.url().origin(),
|
||||
_ => false,
|
||||
} {
|
||||
// TODO (handle foreign fetch unimplemented)
|
||||
}
|
||||
|
||||
|
@ -1044,11 +1042,10 @@ 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);
|
||||
|
@ -1384,11 +1381,10 @@ 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
|
||||
|
|
|
@ -404,10 +404,9 @@ 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 {
|
||||
|
|
|
@ -221,19 +221,25 @@ 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);
|
||||
|
@ -279,12 +285,16 @@ 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);
|
||||
|
@ -344,12 +354,16 @@ 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);
|
||||
|
@ -408,9 +422,11 @@ 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]
|
||||
|
@ -480,9 +496,11 @@ 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]
|
||||
|
|
|
@ -103,12 +103,14 @@ 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,
|
||||
|
@ -179,12 +181,14 @@ 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,
|
||||
|
@ -283,12 +287,14 @@ 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 {
|
||||
|
@ -317,12 +323,14 @@ 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,
|
||||
|
|
|
@ -142,13 +142,15 @@ 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();
|
||||
|
@ -170,13 +172,15 @@ 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();
|
||||
}
|
||||
|
@ -202,13 +206,15 @@ 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();
|
||||
}
|
||||
|
@ -237,13 +243,15 @@ fn test_request_and_response_data_with_network_messages() {
|
|||
});
|
||||
let (devtools_chan, devtools_port) = channel();
|
||||
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();
|
||||
|
||||
|
@ -336,13 +344,15 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() {
|
|||
});
|
||||
let (devtools_chan, devtools_port) = channel();
|
||||
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();
|
||||
|
||||
|
@ -580,13 +590,15 @@ 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
|
||||
|
@ -627,13 +639,15 @@ 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,
|
||||
|
@ -680,13 +694,15 @@ 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]
|
||||
|
@ -727,13 +743,15 @@ 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]
|
||||
|
@ -765,13 +783,15 @@ 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,
|
||||
|
@ -779,9 +799,11 @@ 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]
|
||||
|
@ -813,13 +835,15 @@ 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);
|
||||
}
|
||||
|
@ -850,13 +874,15 @@ 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]
|
||||
|
@ -890,13 +916,15 @@ 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]
|
||||
|
@ -927,13 +955,15 @@ 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]
|
||||
|
@ -967,13 +997,15 @@ 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]
|
||||
|
@ -1004,13 +1036,15 @@ 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]
|
||||
|
@ -1338,13 +1372,15 @@ 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]
|
||||
|
@ -1401,13 +1437,15 @@ 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();
|
||||
// XXX: Not sure about the Some(80) here. origin_url.origin() returns 80 for the port but origin_url returns None.
|
||||
|
@ -1429,13 +1467,15 @@ 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 {
|
||||
|
@ -1448,13 +1488,15 @@ 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