Store the referrer in the Response and return it in Response::metadata().

This commit is contained in:
Ms2ger 2016-10-19 16:31:52 +02:00
parent a66f186866
commit 28d06ab40a
2 changed files with 6 additions and 1 deletions

View file

@ -1024,7 +1024,8 @@ fn http_network_fetch(request: Rc<Request>,
response.status = Some(res.response.status);
response.raw_status = Some((res.response.status_raw().0,
res.response.status_raw().1.as_bytes().to_vec()));
response.headers = res.response.headers.clone();
response.headers = res.response.headers.clone();
response.referrer = request.referrer.borrow().to_url().cloned();
let res_body = response.body.clone();

View file

@ -91,6 +91,7 @@ pub struct Response {
pub body: Arc<Mutex<ResponseBody>>,
pub cache_state: CacheState,
pub https_state: HttpsState,
pub referrer: Option<Url>,
/// [Internal response](https://fetch.spec.whatwg.org/#concept-internal-response), only used if the Response
/// is a filtered response
pub internal_response: Option<Box<Response>>,
@ -111,6 +112,7 @@ impl Response {
body: Arc::new(Mutex::new(ResponseBody::Empty)),
cache_state: CacheState::None,
https_state: HttpsState::None,
referrer: None,
internal_response: None,
return_internal: Cell::new(true)
}
@ -128,6 +130,7 @@ impl Response {
body: Arc::new(Mutex::new(ResponseBody::Empty)),
cache_state: CacheState::None,
https_state: HttpsState::None,
referrer: None,
internal_response: None,
return_internal: Cell::new(true)
}
@ -244,6 +247,7 @@ impl Response {
metadata.headers = Some(Serde(response.headers.clone()));
metadata.status = response.raw_status.clone();
metadata.https_state = response.https_state;
metadata.referrer = response.referrer.clone();
metadata
};