From 504094aa84605c7e11e2b928a8b7f74ced7602bd Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 15 Jan 2015 10:58:11 -0500 Subject: [PATCH] Set cookie headers on the request, rather than the load data, to ensure they are used after redirects occur. --- components/net/http_loader.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 69349234691..de1be171e8f 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -108,14 +108,6 @@ reason: \"certificate verify failed\" }]"; } }; - let (tx, rx) = channel(); - cookies_chan.send(ControlMsg::GetCookiesForUrl(url.clone(), tx, CookieSource::HTTP)); - if let Some(cookies) = rx.recv().unwrap() { - let mut v = Vec::new(); - v.push(cookies.into_bytes()); - load_data.headers.set_raw("Cookie".to_owned(), v); - } - // Avoid automatically preserving request headers when redirects occur. // See https://bugzilla.mozilla.org/show_bug.cgi?id=401564 and // https://bugzilla.mozilla.org/show_bug.cgi?id=216828 @@ -126,6 +118,14 @@ reason: \"certificate verify failed\" }]"; req.headers_mut().set(host); } + let (tx, rx) = channel(); + cookies_chan.send(ControlMsg::GetCookiesForUrl(url.clone(), tx, CookieSource::HTTP)); + if let Some(cookies) = rx.recv().unwrap() { + let mut v = Vec::new(); + v.push(cookies.into_bytes()); + load_data.headers.set_raw("Cookie".to_owned(), v); + } + // FIXME(seanmonstar): use AcceptEncoding from Hyper once available //if !req.headers.has::() { // We currently don't support HTTP Compression (FIXME #2587)