Fix the redirected attribute for Response

This commit is contained in:
Bastien Orivel 2019-12-21 15:09:53 +01:00
parent 566147dab3
commit aa43ce8cf3
5 changed files with 11 additions and 66 deletions

View file

@ -638,6 +638,8 @@ pub struct Metadata {
pub referrer_policy: Option<ReferrerPolicy>,
/// Performance information for navigation events
pub timing: Option<ResourceFetchTiming>,
/// True if the request comes from a redirection
pub redirected: bool,
}
impl Metadata {
@ -655,6 +657,7 @@ impl Metadata {
referrer: None,
referrer_policy: None,
timing: None,
redirected: false,
}
}

View file

@ -310,6 +310,7 @@ impl Response {
metadata.https_state = response.https_state;
metadata.referrer = response.referrer.clone();
metadata.referrer_policy = response.referrer_policy.clone();
metadata.redirected = response.actual_response().url_list.len() > 1;
metadata
};

View file

@ -51,6 +51,7 @@ pub struct Response {
body_promise: DomRefCell<Option<(Rc<Promise>, BodyType)>>,
#[ignore_malloc_size_of = "StreamConsumer"]
stream_consumer: DomRefCell<Option<StreamConsumer>>,
redirected: DomRefCell<bool>,
}
#[allow(non_snake_case)]
@ -69,6 +70,7 @@ impl Response {
body: DomRefCell::new(NetTraitsResponseBody::Empty),
body_promise: DomRefCell::new(None),
stream_consumer: DomRefCell::new(None),
redirected: DomRefCell::new(false),
}
}
@ -414,6 +416,10 @@ impl Response {
*self.url.borrow_mut() = Some(final_url);
}
pub fn set_redirected(&self, is_redirected: bool) {
*self.redirected.borrow_mut() = is_redirected;
}
fn set_response_members_by_type(&self, response_type: DOMResponseType) {
match response_type {
DOMResponseType::Error => {

View file

@ -306,6 +306,7 @@ fn fill_headers_with_metadata(r: DomRoot<Response>, m: Metadata) {
r.set_headers(m.headers);
r.set_raw_status(m.status);
r.set_final_url(m.final_url);
r.set_redirected(m.redirected);
}
/// Convenience function for synchronously loading a whole resource.

View file

@ -1,87 +1,21 @@
[redirect-method.any.worker.html]
[Redirect 301 with GET]
expected: FAIL
[Redirect 301 with POST]
expected: FAIL
[Redirect 301 with HEAD]
expected: FAIL
[Redirect 302 with GET]
expected: FAIL
[Redirect 302 with POST]
expected: FAIL
[Redirect 302 with HEAD]
expected: FAIL
[Redirect 303 with GET]
expected: FAIL
[Redirect 303 with POST]
expected: FAIL
[Redirect 303 with HEAD]
expected: FAIL
[Redirect 307 with GET]
expected: FAIL
[Redirect 307 with POST (string body)]
expected: FAIL
[Redirect 307 with POST (blob body)]
expected: FAIL
[Redirect 307 with HEAD]
expected: FAIL
[Redirect 303 with TESTING]
expected: FAIL
[redirect-method.any.html]
[Redirect 301 with GET]
expected: FAIL
[Redirect 301 with POST]
expected: FAIL
[Redirect 301 with HEAD]
expected: FAIL
[Redirect 302 with GET]
expected: FAIL
[Redirect 302 with POST]
expected: FAIL
[Redirect 302 with HEAD]
expected: FAIL
[Redirect 303 with GET]
expected: FAIL
[Redirect 303 with POST]
expected: FAIL
[Redirect 303 with HEAD]
expected: FAIL
[Redirect 307 with GET]
expected: FAIL
[Redirect 307 with POST (string body)]
expected: FAIL
[Redirect 307 with POST (blob body)]
expected: FAIL
[Redirect 307 with HEAD]
expected: FAIL
[Redirect 303 with TESTING]
expected: FAIL