mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
dom::Response implementation
This commit is contained in:
parent
569599d404
commit
faf32a7cfb
30 changed files with 402 additions and 124 deletions
|
@ -13,7 +13,6 @@ use hyper::header::{AccessControlRequestHeaders, AccessControlRequestMethod, Use
|
|||
use hyper::header::{CacheControl, ContentLanguage, ContentLength, ContentType, Expires, LastModified};
|
||||
use hyper::header::{Headers, HttpDate, Host, Referer as HyperReferer};
|
||||
use hyper::header::{Location, SetCookie, Pragma, Encoding, qitem};
|
||||
use hyper::http::RawStatus;
|
||||
use hyper::method::Method;
|
||||
use hyper::mime::{Mime, TopLevel, SubLevel};
|
||||
use hyper::server::{Handler, Listening, Server};
|
||||
|
@ -27,7 +26,6 @@ use net::http_loader::HttpState;
|
|||
use net_traits::FetchTaskTarget;
|
||||
use net_traits::request::{Origin, RedirectMode, Referer, Request, RequestMode};
|
||||
use net_traits::response::{CacheState, Response, ResponseBody, ResponseType};
|
||||
use std::borrow::Cow;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::rc::Rc;
|
||||
|
@ -834,7 +832,7 @@ fn test_fetch_with_devtools() {
|
|||
|
||||
let httpresponse = DevtoolsHttpResponse {
|
||||
headers: Some(response_headers),
|
||||
status: Some(RawStatus(200, Cow::Borrowed("OK"))),
|
||||
status: Some((200, b"OK".to_vec())),
|
||||
body: None,
|
||||
pipeline_id: pipeline_id,
|
||||
};
|
||||
|
|
|
@ -18,7 +18,6 @@ use hyper::http::RawStatus;
|
|||
use hyper::method::Method;
|
||||
use hyper::mime::{Mime, SubLevel, TopLevel};
|
||||
use hyper::status::StatusCode;
|
||||
use hyper_serde::Serde;
|
||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
|
||||
use net::cookie::Cookie;
|
||||
use net::cookie_storage::CookieStorage;
|
||||
|
@ -80,7 +79,7 @@ fn respond_with_headers(body: Vec<u8>, mut headers: Headers) -> MockResponse {
|
|||
MockResponse::new(
|
||||
headers,
|
||||
StatusCode::Ok,
|
||||
RawStatus(200, Cow::Borrowed("Ok")),
|
||||
RawStatus(200, Cow::Borrowed("OK")),
|
||||
body
|
||||
)
|
||||
}
|
||||
|
@ -537,7 +536,7 @@ fn test_request_and_response_data_with_network_messages() {
|
|||
|
||||
let httpresponse = DevtoolsHttpResponse {
|
||||
headers: Some(response_headers),
|
||||
status: Some(RawStatus(200, Cow::Borrowed("Ok"))),
|
||||
status: Some((200, b"OK".to_vec())),
|
||||
body: None,
|
||||
pipeline_id: pipeline_id,
|
||||
};
|
||||
|
@ -623,7 +622,7 @@ fn test_redirected_request_to_devtools() {
|
|||
|
||||
assert!(devhttprequest.method == Method::Post);
|
||||
assert!(devhttprequest.url == url);
|
||||
assert!(devhttpresponse.status == Some(RawStatus(301, Cow::Borrowed("Moved Permanently"))));
|
||||
assert!(devhttpresponse.status == Some((301, "Moved Permanently".as_bytes().to_vec())));
|
||||
|
||||
let devhttprequest = expect_devtools_http_request(&devtools_port);
|
||||
let devhttpresponse = expect_devtools_http_response(&devtools_port);
|
||||
|
@ -631,7 +630,7 @@ fn test_redirected_request_to_devtools() {
|
|||
|
||||
assert!(devhttprequest.method == Method::Get);
|
||||
assert!(devhttprequest.url == url);
|
||||
assert!(devhttpresponse.status == Some(RawStatus(200, Cow::Borrowed("Ok"))));
|
||||
assert!(devhttpresponse.status == Some((200, b"OK".to_vec())));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1586,7 +1585,7 @@ fn test_auth_ui_sets_header_on_401() {
|
|||
Err(e) => panic!("response contained error {:?}", e),
|
||||
Ok(response) => {
|
||||
assert_eq!(response.metadata.status,
|
||||
Some(Serde(RawStatus(200, Cow::Borrowed("Ok")))));
|
||||
Some((200, b"OK".to_vec())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1621,7 +1620,7 @@ fn test_auth_ui_needs_www_auth() {
|
|||
Err(e) => panic!("response contained error {:?}", e),
|
||||
Ok(response) => {
|
||||
assert_eq!(response.metadata.status,
|
||||
Some(Serde(RawStatus(401, Cow::Borrowed("Unauthorized")))));
|
||||
Some((401, "Unauthorized".as_bytes().to_vec())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1947,7 +1946,7 @@ fn load_request_for_custom_response(expected_body: Vec<u8>) -> (Metadata, String
|
|||
fn test_custom_response() {
|
||||
let expected_body = b"Yay!".to_vec();
|
||||
let (metadata, body) = load_request_for_custom_response(expected_body.clone());
|
||||
assert_eq!(metadata.status, Some(Serde(RawStatus(200, Cow::Borrowed("OK")))));
|
||||
assert_eq!(metadata.status, Some((200, b"OK".to_vec())));
|
||||
assert_eq!(body, String::from_utf8(expected_body).unwrap());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
[response-error.html]
|
||||
type: testharness
|
||||
[Throws RangeError when responseInit's status is 0]
|
||||
expected: FAIL
|
||||
|
||||
[Throws RangeError when responseInit's status is 100]
|
||||
expected: FAIL
|
||||
|
||||
[Throws RangeError when responseInit's status is 199]
|
||||
expected: FAIL
|
||||
|
||||
[Throws RangeError when responseInit's status is 600]
|
||||
expected: FAIL
|
||||
|
||||
[Throws RangeError when responseInit's status is 1000]
|
||||
expected: FAIL
|
||||
|
||||
[Throws TypeError when responseInit's statusText is \n]
|
||||
expected: FAIL
|
||||
|
||||
[Throws TypeError when responseInit's statusText is Ā]
|
||||
expected: FAIL
|
||||
|
||||
[Throws TypeError when building a response with body and a body status of 204]
|
||||
expected: FAIL
|
||||
|
||||
[Throws TypeError when building a response with body and a body status of 205]
|
||||
expected: FAIL
|
||||
|
||||
[Throws TypeError when building a response with body and a body status of 304]
|
||||
expected: FAIL
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
[response-init-001.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[Check default value for body attribute]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
[response-static-redirect.html]
|
||||
type: testharness
|
||||
[Check default redirect response]
|
||||
expected: FAIL
|
||||
|
||||
[Check response returned by static method redirect(), status = 301]
|
||||
expected: FAIL
|
||||
|
||||
[Check response returned by static method redirect(), status = 302]
|
||||
expected: FAIL
|
||||
|
||||
[Check response returned by static method redirect(), status = 303]
|
||||
expected: FAIL
|
||||
|
||||
[Check response returned by static method redirect(), status = 307]
|
||||
expected: FAIL
|
||||
|
||||
[Check response returned by static method redirect(), status = 308]
|
||||
expected: FAIL
|
||||
|
||||
[Check error returned when giving invalid url to redirect()]
|
||||
expected: FAIL
|
||||
|
||||
[Check error returned when giving invalid status to redirect(), status = 200]
|
||||
expected: FAIL
|
||||
|
||||
[Check error returned when giving invalid status to redirect(), status = 309]
|
||||
expected: FAIL
|
||||
|
||||
[Check error returned when giving invalid status to redirect(), status = 400]
|
||||
expected: FAIL
|
||||
|
||||
[Check error returned when giving invalid status to redirect(), status = 500]
|
||||
expected: FAIL
|
||||
|
|
@ -148,6 +148,7 @@ test_interfaces([
|
|||
"RadioNodeList",
|
||||
"Range",
|
||||
"Request",
|
||||
"Response",
|
||||
"Screen",
|
||||
"Storage",
|
||||
"StorageEvent",
|
||||
|
|
|
@ -90,6 +90,7 @@ test_interfaces([
|
|||
"RadioNodeList",
|
||||
"Range",
|
||||
"Request",
|
||||
"Response",
|
||||
"Screen",
|
||||
"Storage",
|
||||
"StorageEvent",
|
||||
|
|
|
@ -60,4 +60,4 @@
|
|||
}, "Check " + attributeName + " init values and associated getter");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
var url = "http://test.url:1234/";
|
||||
test(function() {
|
||||
redirectResponse = Response.redirect(url);
|
||||
assert_equals(redirectResponse.status, 302, "Default redictect status is 302");
|
||||
assert_equals(redirectResponse.status, 302, "Default redirect status is 302");
|
||||
assert_equals(redirectResponse.headers.get("Location"), url,
|
||||
"redirected response has Location header with the correct url");
|
||||
}, "Check default redirect response");
|
||||
|
@ -23,7 +23,7 @@
|
|||
redirectStatus.forEach(function(status) {
|
||||
test(function() {
|
||||
redirectResponse = Response.redirect(url, status);
|
||||
assert_equals(redirectResponse.status, status, "Redictect status is " + status);
|
||||
assert_equals(redirectResponse.status, status, "Redirect status is " + status);
|
||||
}, "Check response returned by static method redirect(), status = " + status);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue