mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Fix the redirected attribute for Response
This commit is contained in:
parent
566147dab3
commit
aa43ce8cf3
5 changed files with 11 additions and 66 deletions
|
@ -638,6 +638,8 @@ pub struct Metadata {
|
||||||
pub referrer_policy: Option<ReferrerPolicy>,
|
pub referrer_policy: Option<ReferrerPolicy>,
|
||||||
/// Performance information for navigation events
|
/// Performance information for navigation events
|
||||||
pub timing: Option<ResourceFetchTiming>,
|
pub timing: Option<ResourceFetchTiming>,
|
||||||
|
/// True if the request comes from a redirection
|
||||||
|
pub redirected: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Metadata {
|
impl Metadata {
|
||||||
|
@ -655,6 +657,7 @@ impl Metadata {
|
||||||
referrer: None,
|
referrer: None,
|
||||||
referrer_policy: None,
|
referrer_policy: None,
|
||||||
timing: None,
|
timing: None,
|
||||||
|
redirected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,6 +310,7 @@ impl Response {
|
||||||
metadata.https_state = response.https_state;
|
metadata.https_state = response.https_state;
|
||||||
metadata.referrer = response.referrer.clone();
|
metadata.referrer = response.referrer.clone();
|
||||||
metadata.referrer_policy = response.referrer_policy.clone();
|
metadata.referrer_policy = response.referrer_policy.clone();
|
||||||
|
metadata.redirected = response.actual_response().url_list.len() > 1;
|
||||||
metadata
|
metadata
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ pub struct Response {
|
||||||
body_promise: DomRefCell<Option<(Rc<Promise>, BodyType)>>,
|
body_promise: DomRefCell<Option<(Rc<Promise>, BodyType)>>,
|
||||||
#[ignore_malloc_size_of = "StreamConsumer"]
|
#[ignore_malloc_size_of = "StreamConsumer"]
|
||||||
stream_consumer: DomRefCell<Option<StreamConsumer>>,
|
stream_consumer: DomRefCell<Option<StreamConsumer>>,
|
||||||
|
redirected: DomRefCell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -69,6 +70,7 @@ impl Response {
|
||||||
body: DomRefCell::new(NetTraitsResponseBody::Empty),
|
body: DomRefCell::new(NetTraitsResponseBody::Empty),
|
||||||
body_promise: DomRefCell::new(None),
|
body_promise: DomRefCell::new(None),
|
||||||
stream_consumer: 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);
|
*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) {
|
fn set_response_members_by_type(&self, response_type: DOMResponseType) {
|
||||||
match response_type {
|
match response_type {
|
||||||
DOMResponseType::Error => {
|
DOMResponseType::Error => {
|
||||||
|
|
|
@ -306,6 +306,7 @@ fn fill_headers_with_metadata(r: DomRoot<Response>, m: Metadata) {
|
||||||
r.set_headers(m.headers);
|
r.set_headers(m.headers);
|
||||||
r.set_raw_status(m.status);
|
r.set_raw_status(m.status);
|
||||||
r.set_final_url(m.final_url);
|
r.set_final_url(m.final_url);
|
||||||
|
r.set_redirected(m.redirected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function for synchronously loading a whole resource.
|
/// Convenience function for synchronously loading a whole resource.
|
||||||
|
|
|
@ -1,87 +1,21 @@
|
||||||
[redirect-method.any.worker.html]
|
[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]
|
[Redirect 303 with GET]
|
||||||
expected: FAIL
|
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)]
|
[Redirect 307 with POST (string body)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Redirect 307 with POST (blob body)]
|
[Redirect 307 with POST (blob body)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Redirect 307 with HEAD]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Redirect 303 with TESTING]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
||||||
[redirect-method.any.html]
|
[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]
|
[Redirect 303 with GET]
|
||||||
expected: FAIL
|
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)]
|
[Redirect 307 with POST (string body)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Redirect 307 with POST (blob body)]
|
[Redirect 307 with POST (blob body)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Redirect 307 with HEAD]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Redirect 303 with TESTING]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue