Skip to content

Commit

Permalink
Thread the status through navigation redirects
Browse files Browse the repository at this point in the history
This is necessary because status codes affect whether the redirect is
done with the same HTTP method or a different one.

This is part of #21886, but there's also a flaw in how iframes are handled
that is causing the redirect to take over the entire window, so this
commit doesn't entirely fix slither.io.
  • Loading branch information
notriddle committed Oct 13, 2018
1 parent bf192ca commit 3b1bfa3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/constellation/network_listener.rs
Expand Up @@ -113,6 +113,9 @@ impl NetworkListener {
location_url: metadata.location_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(),
status_code: metadata.status.as_ref()
.map(|&(code, _)| code)
.unwrap_or(200),
}); });


// XXXManishearth we don't have the cancel_chan anymore and // XXXManishearth we don't have the cancel_chan anymore and
Expand Down
2 changes: 2 additions & 0 deletions components/net_traits/response.rs
Expand Up @@ -82,6 +82,7 @@ pub struct ResponseInit {
serialize_with = "::hyper_serde::serialize")] serialize_with = "::hyper_serde::serialize")]
#[ignore_malloc_size_of = "Defined in hyper"] #[ignore_malloc_size_of = "Defined in hyper"]
pub headers: Headers, pub headers: Headers,
pub status_code: u16,
pub referrer: Option<ServoUrl>, pub referrer: Option<ServoUrl>,
pub location_url: Option<Result<ServoUrl, String>>, pub location_url: Option<Result<ServoUrl, String>>,
} }
Expand Down Expand Up @@ -147,6 +148,7 @@ impl Response {
res.location_url = init.location_url; res.location_url = init.location_url;
res.headers = init.headers; res.headers = init.headers;
res.referrer = init.referrer; res.referrer = init.referrer;
res.status = Some(StatusCode::from_u16(init.status_code));
res res
} }


Expand Down

0 comments on commit 3b1bfa3

Please sign in to comment.