Unify the get/set scookie APIs to make them both deal with raw strings.

This commit is contained in:
Josh Matthews 2015-02-01 11:51:27 +01:00
parent 504094aa84
commit 824709f178
2 changed files with 17 additions and 10 deletions

View file

@ -11,7 +11,7 @@ use log;
use std::collections::HashSet;
use file_loader;
use hyper::client::Request;
use hyper::header::common::{ContentLength, ContentType, Host, Location, SetCookie};
use hyper::header::common::{ContentLength, ContentType, Host, Location};
use hyper::HttpError;
use hyper::method::Method;
use hyper::net::HttpConnector;
@ -189,9 +189,14 @@ reason: \"certificate verify failed\" }]";
}
}
if let Some(&SetCookie(ref cookies)) = response.headers.get::<SetCookie>() {
cookies_chan.send(ControlMsg::SetCookies(cookies.clone(), url.clone(),
CookieSource::HTTP));
if let Some(cookies) = response.headers.get_raw("set-cookie") {
for cookie in cookies.iter() {
if let Ok(cookies) = String::from_utf8(cookie.clone()) {
cookies_chan.send(ControlMsg::SetCookiesForUrl(url.clone(),
cookies,
CookieSource::HTTP));
}
}
}
if response.status.class() == StatusClass::Redirection {