mirror of
https://github.com/servo/servo.git
synced 2025-07-25 08:10:21 +01:00
Add location_url to Metadata struct
This commit is contained in:
parent
d6c197b40c
commit
5b69d18fca
3 changed files with 8 additions and 0 deletions
|
@ -103,6 +103,7 @@ impl NetworkListener {
|
||||||
|
|
||||||
self.res_init = Some(ResponseInit {
|
self.res_init = Some(ResponseInit {
|
||||||
url: metadata.final_url.clone(),
|
url: metadata.final_url.clone(),
|
||||||
|
location_url: metadata.location_url.clone(),
|
||||||
headers: headers.clone().into_inner(),
|
headers: headers.clone().into_inner(),
|
||||||
referrer: metadata.referrer.clone(),
|
referrer: metadata.referrer.clone(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -411,6 +411,9 @@ pub struct Metadata {
|
||||||
/// Final URL after redirects.
|
/// Final URL after redirects.
|
||||||
pub final_url: ServoUrl,
|
pub final_url: ServoUrl,
|
||||||
|
|
||||||
|
/// Location URL from the response headers.
|
||||||
|
pub location_url: Option<Result<ServoUrl, String>>,
|
||||||
|
|
||||||
#[ignore_heap_size_of = "Defined in hyper"]
|
#[ignore_heap_size_of = "Defined in hyper"]
|
||||||
/// MIME type / subtype.
|
/// MIME type / subtype.
|
||||||
pub content_type: Option<Serde<ContentType>>,
|
pub content_type: Option<Serde<ContentType>>,
|
||||||
|
@ -440,6 +443,7 @@ impl Metadata {
|
||||||
pub fn default(url: ServoUrl) -> Self {
|
pub fn default(url: ServoUrl) -> Self {
|
||||||
Metadata {
|
Metadata {
|
||||||
final_url: url,
|
final_url: url,
|
||||||
|
location_url: None,
|
||||||
content_type: None,
|
content_type: None,
|
||||||
charset: None,
|
charset: None,
|
||||||
headers: None,
|
headers: None,
|
||||||
|
|
|
@ -82,6 +82,7 @@ pub struct ResponseInit {
|
||||||
#[ignore_heap_size_of = "Defined in hyper"]
|
#[ignore_heap_size_of = "Defined in hyper"]
|
||||||
pub headers: Headers,
|
pub headers: Headers,
|
||||||
pub referrer: Option<ServoUrl>,
|
pub referrer: Option<ServoUrl>,
|
||||||
|
pub location_url: Option<Result<ServoUrl, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [Response](https://fetch.spec.whatwg.org/#concept-response) as defined by the Fetch spec
|
/// A [Response](https://fetch.spec.whatwg.org/#concept-response) as defined by the Fetch spec
|
||||||
|
@ -138,6 +139,7 @@ impl Response {
|
||||||
|
|
||||||
pub fn from_init(init: ResponseInit) -> Response {
|
pub fn from_init(init: ResponseInit) -> Response {
|
||||||
let mut res = Response::new(init.url);
|
let mut res = Response::new(init.url);
|
||||||
|
res.location_url = init.location_url;
|
||||||
res.headers = init.headers;
|
res.headers = init.headers;
|
||||||
res.referrer = init.referrer;
|
res.referrer = init.referrer;
|
||||||
res
|
res
|
||||||
|
@ -287,6 +289,7 @@ impl Response {
|
||||||
Some(&ContentType(ref mime)) => Some(mime),
|
Some(&ContentType(ref mime)) => Some(mime),
|
||||||
None => None,
|
None => None,
|
||||||
});
|
});
|
||||||
|
metadata.location_url = response.location_url.clone();
|
||||||
metadata.headers = Some(Serde(response.headers.clone()));
|
metadata.headers = Some(Serde(response.headers.clone()));
|
||||||
metadata.status = response.raw_status.clone();
|
metadata.status = response.raw_status.clone();
|
||||||
metadata.https_state = response.https_state;
|
metadata.https_state = response.https_state;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue