mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Tests rewriting redirects of POST as GET
This commit is contained in:
parent
2eaac7e3f9
commit
04b7ce0afa
2 changed files with 36 additions and 7 deletions
|
@ -208,6 +208,32 @@ impl HttpRequest for AssertMustHaveBodyRequest {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_load_when_redirecting_from_a_post_should_rewrite_next_request_as_get() {
|
||||
struct Factory;
|
||||
|
||||
impl HttpRequestFactory for Factory {
|
||||
type R=MockRequest;
|
||||
|
||||
fn create(&self, url: Url, method: Method) -> Result<MockRequest, LoadError> {
|
||||
if url.domain().unwrap() == "mozilla.com" {
|
||||
assert_eq!(Method::Post, method);
|
||||
Ok(MockRequest::new(RequestType::Redirect("http://mozilla.org".to_string())))
|
||||
} else {
|
||||
assert_eq!(Method::Get, method);
|
||||
Ok(MockRequest::new(RequestType::Text(<[_]>::to_vec("Yay!".as_bytes()))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let url = Url::parse("http://mozilla.com").unwrap();
|
||||
let resource_mgr = new_resource_task(None, None);
|
||||
let mut load_data = LoadData::new(url.clone(), None);
|
||||
load_data.method = Method::Post;
|
||||
|
||||
let _ = load::<MockRequest>(load_data, resource_mgr, None, &Factory);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_load_should_decode_the_response_as_deflate_when_response_headers_have_content_encoding_deflate() {
|
||||
struct Factory;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue