Set cookie headers on the request, rather than the load data, to ensure they are used after redirects occur.

This commit is contained in:
Josh Matthews 2015-01-15 10:58:11 -05:00
parent 14df9f8a70
commit 504094aa84

View file

@ -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::<AcceptEncoding>() {
// We currently don't support HTTP Compression (FIXME #2587)