aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/net/http_loader.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2016-04-12 18:23:18 -0400
committerJosh Matthews <josh@joshmatthews.net>2016-04-15 01:46:01 -0400
commitd1b07673b8837f5f5dd97466a617853b576a865e (patch)
treee6c1ae997aa46940b96f460ced577f8de710c5b1 /tests/unit/net/http_loader.rs
parentf712ddb0db3bd776c1ccbb44d9d02236d7895ddc (diff)
downloadservo-d1b07673b8837f5f5dd97466a617853b576a865e.tar.gz
servo-d1b07673b8837f5f5dd97466a617853b576a865e.zip
Convert AssertMustNotIncludeHeadersRequestFactory.
Diffstat (limited to 'tests/unit/net/http_loader.rs')
-rw-r--r--tests/unit/net/http_loader.rs45
1 files changed, 8 insertions, 37 deletions
diff --git a/tests/unit/net/http_loader.rs b/tests/unit/net/http_loader.rs
index 4dfd29c9b25..8ac53cebc9f 100644
--- a/tests/unit/net/http_loader.rs
+++ b/tests/unit/net/http_loader.rs
@@ -251,50 +251,21 @@ fn assert_cookie_for_domain(cookie_jar: Arc<RwLock<CookieStorage>>, domain: &str
}
}
-struct AssertRequestMustNotIncludeHeaders {
- headers_not_expected: Vec<String>,
- request_headers: Headers,
- t: ResponseType
-}
-
-impl AssertRequestMustNotIncludeHeaders {
- fn new(t: ResponseType, headers_not_expected: Vec<String>) -> Self {
- assert!(headers_not_expected.len() != 0);
- AssertRequestMustNotIncludeHeaders {
- headers_not_expected: headers_not_expected,
- request_headers: Headers::new(), t: t }
- }
-}
-
-impl HttpRequest for AssertRequestMustNotIncludeHeaders {
- type R = MockResponse;
-
- fn headers_mut(&mut self) -> &mut Headers { &mut self.request_headers }
-
- fn send(self, _: &Option<Vec<u8>>) -> Result<MockResponse, LoadError> {
- for header in &self.headers_not_expected {
- assert!(self.request_headers.get_raw(header).is_none());
- }
-
- response_for_request_type(self.t)
- }
-}
-
struct AssertMustNotIncludeHeadersRequestFactory {
headers_not_expected: Vec<String>,
body: Vec<u8>
}
impl HttpRequestFactory for AssertMustNotIncludeHeadersRequestFactory {
- type R = AssertRequestMustNotIncludeHeaders;
+ type R = MockRequest;
- fn create(&self, _: Url, _: Method) -> Result<AssertRequestMustNotIncludeHeaders, LoadError> {
- Ok(
- AssertRequestMustNotIncludeHeaders::new(
- ResponseType::Text(self.body.clone()),
- self.headers_not_expected.clone()
- )
- )
+ fn create_with_headers(&self, _: Url, _: Method, headers: Headers) -> Result<MockRequest, LoadError> {
+ assert!(self.headers_not_expected.len() != 0);
+ for header in &self.headers_not_expected {
+ assert!(headers.get_raw(header).is_none());
+ }
+
+ Ok(MockRequest::new(ResponseType::Text(self.body.clone())))
}
}