mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Convert remaining factories that don't make use of headers.
This commit is contained in:
parent
d1b07673b8
commit
4cb7dfbc59
1 changed files with 16 additions and 16 deletions
|
@ -398,7 +398,7 @@ fn test_request_and_response_data_with_network_messages() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let mut headers = Headers::new();
|
||||
headers.set(Host { hostname: "foo.bar".to_owned(), port: None });
|
||||
Ok(MockRequest::new(
|
||||
|
@ -473,7 +473,7 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let mut headers = Headers::new();
|
||||
headers.set(Host { hostname: "foo.bar".to_owned(), port: None });
|
||||
Ok(MockRequest::new(
|
||||
|
@ -504,7 +504,7 @@ fn test_load_when_redirecting_from_a_post_should_rewrite_next_request_as_get() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, url: Url, method: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, url: Url, method: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
if url.domain().unwrap() == "mozilla.com" {
|
||||
assert_eq!(Method::Post, method);
|
||||
Ok(MockRequest::new(ResponseType::Redirect("http://mozilla.org".to_owned())))
|
||||
|
@ -533,7 +533,7 @@ fn test_load_should_decode_the_response_as_deflate_when_response_headers_have_co
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let mut e = DeflateEncoder::new(Vec::new(), Compression::Default);
|
||||
e.write(b"Yay!").unwrap();
|
||||
let encoded_content = e.finish().unwrap();
|
||||
|
@ -567,7 +567,7 @@ fn test_load_should_decode_the_response_as_gzip_when_response_headers_have_conte
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let mut e = GzEncoder::new(Vec::new(), Compression::Default);
|
||||
e.write(b"Yay!").unwrap();
|
||||
let encoded_content = e.finish().unwrap();
|
||||
|
@ -601,7 +601,7 @@ fn test_load_doesnt_send_request_body_on_any_redirect() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = AssertMustHaveBodyRequest;
|
||||
|
||||
fn create(&self, url: Url, _: Method) -> Result<AssertMustHaveBodyRequest, LoadError> {
|
||||
fn create_with_headers(&self, url: Url, _: Method, _: Headers) -> Result<AssertMustHaveBodyRequest, LoadError> {
|
||||
if url.domain().unwrap() == "mozilla.com" {
|
||||
Ok(
|
||||
AssertMustHaveBodyRequest::new(
|
||||
|
@ -642,7 +642,7 @@ fn test_load_doesnt_add_host_to_sts_list_when_url_is_http_even_if_sts_headers_ar
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let content = <[_]>::to_vec("Yay!".as_bytes());
|
||||
let mut headers = Headers::new();
|
||||
headers.set(StrictTransportSecurity::excluding_subdomains(31536000));
|
||||
|
@ -674,7 +674,7 @@ fn test_load_adds_host_to_sts_list_when_url_is_https_and_sts_headers_are_present
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let content = <[_]>::to_vec("Yay!".as_bytes());
|
||||
let mut headers = Headers::new();
|
||||
headers.set(StrictTransportSecurity::excluding_subdomains(31536000));
|
||||
|
@ -706,7 +706,7 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let content = <[_]>::to_vec("Yay!".as_bytes());
|
||||
let mut headers = Headers::new();
|
||||
headers.set(SetCookie(vec![CookiePair::new("mozillaIs".to_owned(), "theBest".to_owned())]));
|
||||
|
@ -846,7 +846,7 @@ fn test_cookie_set_with_httponly_should_not_be_available_using_getcookiesforurl(
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let content = <[_]>::to_vec("Yay!".as_bytes());
|
||||
let mut headers = Headers::new();
|
||||
headers.set_raw("set-cookie", vec![b"mozillaIs=theBest; HttpOnly;".to_vec()]);
|
||||
|
@ -878,7 +878,7 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let content = <[_]>::to_vec("Yay!".as_bytes());
|
||||
let mut headers = Headers::new();
|
||||
headers.set_raw("set-cookie", vec![b"mozillaIs=theBest; Secure;".to_vec()]);
|
||||
|
@ -1061,7 +1061,7 @@ fn test_load_errors_when_there_a_redirect_loop() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, url: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, url: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
if url.domain().unwrap() == "mozilla.com" {
|
||||
Ok(MockRequest::new(ResponseType::Redirect("http://mozilla.org".to_owned())))
|
||||
} else if url.domain().unwrap() == "mozilla.org" {
|
||||
|
@ -1094,7 +1094,7 @@ fn test_load_errors_when_there_is_too_many_redirects() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, url: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, url: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
if url.domain().unwrap() == "mozilla.com" {
|
||||
Ok(MockRequest::new(ResponseType::Redirect(format!("{}/1", url.serialize()))))
|
||||
} else {
|
||||
|
@ -1125,7 +1125,7 @@ fn test_load_follows_a_redirect() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, url: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, url: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
if url.domain().unwrap() == "mozilla.com" {
|
||||
Ok(MockRequest::new(ResponseType::Redirect("http://mozilla.org".to_owned())))
|
||||
} else if url.domain().unwrap() == "mozilla.org" {
|
||||
|
@ -1163,7 +1163,7 @@ struct DontConnectFactory;
|
|||
impl HttpRequestFactory for DontConnectFactory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, url: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, url: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
Err(LoadError::Connection(url, "should not have connected".to_owned()))
|
||||
}
|
||||
}
|
||||
|
@ -1217,7 +1217,7 @@ fn test_load_errors_when_cancelled() {
|
|||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, _: Url, _: Method) -> Result<MockRequest, LoadError> {
|
||||
fn create_with_headers(&self, _: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
let mut headers = Headers::new();
|
||||
headers.set(Host { hostname: "Kaboom!".to_owned(), port: None });
|
||||
Ok(MockRequest::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue