diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 6578a83b8c2..5f1d17bd010 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -154,9 +154,9 @@ fn load_for_consumer(load_data: LoadData, let ui_provider = TFDProvider; let context = load_data.context.clone(); - match load::(load_data, &ui_provider, &http_state, - devtools_chan, &factory, - user_agent, &cancel_listener) { + match load(load_data, &ui_provider, &http_state, + devtools_chan, &factory, + user_agent, &cancel_listener) { Err(LoadError::UnsupportedScheme(url)) => { let s = format!("{} request, but we don't support that scheme", &*url.scheme); send_error(url, s, start_chan) diff --git a/tests/unit/net/http_loader.rs b/tests/unit/net/http_loader.rs index 10aa01d3e4c..d5f70bd3b90 100644 --- a/tests/unit/net/http_loader.rs +++ b/tests/unit/net/http_loader.rs @@ -474,22 +474,22 @@ fn test_check_default_headers_loaded_in_every_request() { headers.set(UserAgent(DEFAULT_USER_AGENT.to_owned())); // Testing for method.GET - let _ = load::(load_data.clone(), &ui_provider, &http_state, None, - &AssertMustHaveHeadersRequestFactory { - expected_headers: headers.clone(), - body: <[_]>::to_vec(&[]) - }, DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); + let _ = load(load_data.clone(), &ui_provider, &http_state, None, + &AssertMustHaveHeadersRequestFactory { + expected_headers: headers.clone(), + body: <[_]>::to_vec(&[]) + }, DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); // Testing for method.POST load_data.method = Method::Post; headers.set(ContentLength(0 as u64)); - let _ = load::(load_data.clone(), &ui_provider, &http_state, None, - &AssertMustHaveHeadersRequestFactory { - expected_headers: headers, - body: <[_]>::to_vec(&[]) - }, DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); + let _ = load(load_data.clone(), &ui_provider, &http_state, None, + &AssertMustHaveHeadersRequestFactory { + expected_headers: headers, + body: <[_]>::to_vec(&[]) + }, DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); } #[test] @@ -506,7 +506,7 @@ fn test_load_when_request_is_not_get_or_head_and_there_is_no_body_content_length let mut content_length = Headers::new(); content_length.set(ContentLength(0)); - let _ = load::( + let _ = load( load_data.clone(), &ui_provider, &http_state, None, &AssertMustIncludeHeadersRequestFactory { expected_headers: content_length, @@ -541,8 +541,8 @@ fn test_request_and_response_data_with_network_messages() { let mut request_headers = Headers::new(); request_headers.set(Host { hostname: "bar.foo".to_owned(), port: None }); load_data.headers = request_headers.clone(); - let _ = load::(load_data, &ui_provider, &http_state, Some(devtools_chan), &Factory, - DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); + let _ = load(load_data, &ui_provider, &http_state, Some(devtools_chan), &Factory, + DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); // notification received from devtools let devhttprequest = expect_devtools_http_request(&devtools_port); @@ -611,8 +611,8 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() { let url = Url::parse("https://mozilla.com").unwrap(); let (devtools_chan, devtools_port) = mpsc::channel::(); let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None); - let _ = load::(load_data, &ui_provider, &http_state, Some(devtools_chan), &Factory, - DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); + let _ = load(load_data, &ui_provider, &http_state, Some(devtools_chan), &Factory, + DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); // notification received from devtools assert!(devtools_port.try_recv().is_err()); @@ -645,8 +645,8 @@ fn test_load_when_redirecting_from_a_post_should_rewrite_next_request_as_get() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::(load_data, &ui_provider, &http_state, None, &Factory, - DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); + let _ = load(load_data, &ui_provider, &http_state, None, &Factory, + DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)); } #[test] @@ -673,7 +673,7 @@ fn test_load_should_decode_the_response_as_deflate_when_response_headers_have_co let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let mut response = load::( + let mut response = load( load_data, &ui_provider, &http_state, None, &Factory, DEFAULT_USER_AGENT.to_owned(), @@ -706,7 +706,7 @@ fn test_load_should_decode_the_response_as_gzip_when_response_headers_have_conte let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let mut response = load::( + let mut response = load( load_data, &ui_provider, &http_state, None, &Factory, @@ -750,7 +750,7 @@ fn test_load_doesnt_send_request_body_on_any_redirect() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::( + let _ = load( load_data, &ui_provider, &http_state, None, &Factory, @@ -780,12 +780,12 @@ fn test_load_doesnt_add_host_to_sts_list_when_url_is_http_even_if_sts_headers_ar let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &Factory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &Factory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); assert_eq!(http_state.hsts_list.read().unwrap().is_host_secure("mozilla.com"), false); } @@ -812,12 +812,12 @@ fn test_load_adds_host_to_sts_list_when_url_is_https_and_sts_headers_are_present let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &Factory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &Factory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); assert!(http_state.hsts_list.read().unwrap().is_host_secure("mozilla.com")); } @@ -846,12 +846,12 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_ let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &Factory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &Factory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", "mozillaIs=theBest"); } @@ -880,12 +880,12 @@ fn test_load_sets_requests_cookies_header_for_url_by_getting_cookies_from_the_re let mut cookie = Headers::new(); cookie.set(CookieHeader(vec![CookiePair::new("mozillaIs".to_owned(), "theBest".to_owned())])); - let _ = load::(load_data.clone(), &ui_provider, &http_state, None, - &AssertMustIncludeHeadersRequestFactory { - expected_headers: cookie, - body: <[_]>::to_vec(&*load_data.data.unwrap()) - }, DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data.clone(), &ui_provider, &http_state, None, + &AssertMustIncludeHeadersRequestFactory { + expected_headers: cookie, + body: <[_]>::to_vec(&*load_data.data.unwrap()) + }, DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); } #[test] @@ -922,7 +922,7 @@ fn test_load_sends_secure_cookie_if_http_changed_to_https_due_to_entry_in_hsts_s let mut headers = Headers::new(); headers.set_raw("Cookie".to_owned(), vec![<[_]>::to_vec("mozillaIs=theBest".as_bytes())]); - let _ = load::( + let _ = load( load_data.clone(), &ui_provider, &http_state, None, &AssertMustIncludeHeadersRequestFactory { expected_headers: headers, @@ -954,7 +954,7 @@ fn test_load_sends_cookie_if_nonhttp() { let mut headers = Headers::new(); headers.set_raw("Cookie".to_owned(), vec![<[_]>::to_vec("mozillaIs=theBest".as_bytes())]); - let _ = load::( + let _ = load( load_data.clone(), &ui_provider, &http_state, None, &AssertMustIncludeHeadersRequestFactory { expected_headers: headers, @@ -983,12 +983,12 @@ fn test_cookie_set_with_httponly_should_not_be_available_using_getcookiesforurl( let ui_provider = TestProvider::new(); let load_data = LoadData::new(LoadContext::Browsing, url.clone(), None); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &Factory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &Factory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); let mut cookie_jar = http_state.cookie_jar.write().unwrap(); assert!(cookie_jar.cookies_for_url(&url, CookieSource::NonHTTP).is_none()); @@ -1013,12 +1013,12 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() { let ui_provider = TestProvider::new(); let load_data = LoadData::new(LoadContext::Browsing, Url::parse("http://mozilla.com").unwrap(), None); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &Factory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &Factory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", ""); } @@ -1048,7 +1048,7 @@ fn test_when_cookie_set_marked_httpsonly_secure_isnt_sent_on_http_request() { assert_cookie_for_domain(http_state.cookie_jar.clone(), "https://mozilla.com", "mozillaIs=theBest"); - let _ = load::( + let _ = load( load_data.clone(), &ui_provider, &http_state, None, &AssertMustNotIncludeHeadersRequestFactory { headers_not_expected: vec!["Cookie".to_owned()], @@ -1070,12 +1070,12 @@ fn test_load_sets_content_length_to_length_of_request_body() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::(load_data.clone(), &ui_provider, &http_state, - None, &AssertMustIncludeHeadersRequestFactory { - expected_headers: content_len_headers, - body: <[_]>::to_vec(&*load_data.data.unwrap()) - }, DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data.clone(), &ui_provider, &http_state, + None, &AssertMustIncludeHeadersRequestFactory { + expected_headers: content_len_headers, + body: <[_]>::to_vec(&*load_data.data.unwrap()) + }, DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); } #[test] @@ -1093,14 +1093,14 @@ fn test_load_uses_explicit_accept_from_headers_in_load_data() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &AssertMustIncludeHeadersRequestFactory { - expected_headers: accept_headers, - body: <[_]>::to_vec("Yay!".as_bytes()) - }, DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &AssertMustIncludeHeadersRequestFactory { + expected_headers: accept_headers, + body: <[_]>::to_vec("Yay!".as_bytes()) + }, DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); } #[test] @@ -1120,14 +1120,14 @@ fn test_load_sets_default_accept_to_html_xhtml_xml_and_then_anything_else() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &AssertMustIncludeHeadersRequestFactory { - expected_headers: accept_headers, - body: <[_]>::to_vec("Yay!".as_bytes()) - }, DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &AssertMustIncludeHeadersRequestFactory { + expected_headers: accept_headers, + body: <[_]>::to_vec("Yay!".as_bytes()) + }, DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); } #[test] @@ -1143,14 +1143,14 @@ fn test_load_uses_explicit_accept_encoding_from_load_data_headers() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &AssertMustIncludeHeadersRequestFactory { - expected_headers: accept_encoding_headers, - body: <[_]>::to_vec("Yay!".as_bytes()) - }, DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &AssertMustIncludeHeadersRequestFactory { + expected_headers: accept_encoding_headers, + body: <[_]>::to_vec("Yay!".as_bytes()) + }, DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); } #[test] @@ -1167,14 +1167,14 @@ fn test_load_sets_default_accept_encoding_to_gzip_and_deflate() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - let _ = load::(load_data, - &ui_provider, &http_state, - None, - &AssertMustIncludeHeadersRequestFactory { - expected_headers: accept_encoding_headers, - body: <[_]>::to_vec("Yay!".as_bytes()) - }, DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)); + let _ = load(load_data, + &ui_provider, &http_state, + None, + &AssertMustIncludeHeadersRequestFactory { + expected_headers: accept_encoding_headers, + body: <[_]>::to_vec("Yay!".as_bytes()) + }, DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)); } #[test] @@ -1201,8 +1201,8 @@ fn test_load_errors_when_there_a_redirect_loop() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - match load::(load_data, &ui_provider, &http_state, None, &Factory, - DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) { + match load(load_data, &ui_provider, &http_state, None, &Factory, + DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) { Err(LoadError::InvalidRedirect(_, msg)) => { assert_eq!(msg, "redirect loop"); }, @@ -1232,8 +1232,8 @@ fn test_load_errors_when_there_is_too_many_redirects() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - match load::(load_data, &ui_provider, &http_state, None, &Factory, - DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) { + match load(load_data, &ui_provider, &http_state, None, &Factory, + DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) { Err(LoadError::MaxRedirects(url)) => { assert_eq!(url.domain().unwrap(), "mozilla.com") }, @@ -1271,8 +1271,8 @@ fn test_load_follows_a_redirect() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - match load::(load_data, &ui_provider, &http_state, None, &Factory, - DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) { + match load(load_data, &ui_provider, &http_state, None, &Factory, + DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) { Err(e) => panic!("expected to follow a redirect {:?}", e), Ok(mut lr) => { let response = read_response(&mut lr); @@ -1299,12 +1299,12 @@ fn test_load_errors_when_scheme_is_not_http_or_https() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - match load::(load_data, - &ui_provider, &http_state, - None, - &DontConnectFactory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)) { + match load(load_data, + &ui_provider, &http_state, + None, + &DontConnectFactory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)) { Err(LoadError::UnsupportedScheme(_)) => {} _ => panic!("expected ftp scheme to be unsupported") } @@ -1318,12 +1318,12 @@ fn test_load_errors_when_viewing_source_and_inner_url_scheme_is_not_http_or_http let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - match load::(load_data, - &ui_provider, &http_state, - None, - &DontConnectFactory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)) { + match load(load_data, + &ui_provider, &http_state, + None, + &DontConnectFactory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)) { Err(LoadError::UnsupportedScheme(_)) => {} _ => panic!("expected ftp scheme to be unsupported") } @@ -1360,12 +1360,12 @@ fn test_load_errors_when_cancelled() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - match load::(load_data, - &ui_provider, &http_state, - None, - &Factory, - DEFAULT_USER_AGENT.to_owned(), - &cancel_listener) { + match load(load_data, + &ui_provider, &http_state, + None, + &Factory, + DEFAULT_USER_AGENT.to_owned(), + &cancel_listener) { Err(LoadError::Cancelled(_, _)) => (), _ => panic!("expected load cancelled error!") } @@ -1428,12 +1428,12 @@ fn test_redirect_from_x_to_y_provides_y_cookies_from_y() { cookie_jar.push(cookie_y, CookieSource::HTTP); } - match load::(load_data, - &ui_provider, &http_state, - None, - &Factory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)) { + match load(load_data, + &ui_provider, &http_state, + None, + &Factory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)) { Err(e) => panic!("expected to follow a redirect {:?}", e), Ok(mut lr) => { let response = read_response(&mut lr); @@ -1476,12 +1476,12 @@ fn test_redirect_from_x_to_x_provides_x_with_cookie_from_first_response() { let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - match load::(load_data, - &ui_provider, &http_state, - None, - &Factory, - DEFAULT_USER_AGENT.to_owned(), - &CancellationListener::new(None)) { + match load(load_data, + &ui_provider, &http_state, + None, + &Factory, + DEFAULT_USER_AGENT.to_owned(), + &CancellationListener::new(None)) { Err(e) => panic!("expected to follow a redirect {:?}", e), Ok(mut lr) => { let response = read_response(&mut lr); @@ -1518,7 +1518,7 @@ fn test_if_auth_creds_not_in_url_but_in_cache_it_sets_it() { ) ); - let _ = load::( + let _ = load( load_data.clone(), &ui_provider, &http_state, None, &AssertMustIncludeHeadersRequestFactory { expected_headers: auth_header, @@ -1545,7 +1545,7 @@ fn test_auth_ui_sets_header_on_401() { let load_data = LoadData::new(LoadContext::Browsing, url, None); - match load::( + match load( load_data.clone(), &ui_provider, &http_state, None, &AssertAuthHeaderRequestFactory { expected_headers: auth_header,