servo: Merge #5424 - Add Accept header to HTTP loader (from bdero:bdero/accept-header); r=jdm

The value of the header is: `text/html;q=0.9,*/*;q=0.8`

Closes #5399

Source-Repo: https://github.com/servo/servo
Source-Revision: 21c38d0de8e82e29d187929535a73bfd297538b8
This commit is contained in:
Brandon DeRosier 2015-04-26 22:13:30 -05:00
Родитель 086acefea5
Коммит 478a939a2f
1 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -12,7 +12,7 @@ use std::collections::HashSet;
use file_loader;
use flate2::read::{DeflateDecoder, GzDecoder};
use hyper::client::Request;
use hyper::header::{AcceptEncoding, ContentLength, ContentType, Host, Location};
use hyper::header::{AcceptEncoding, Accept, ContentLength, ContentType, Host, Location, qitem, Quality, QualityItem};
use hyper::HttpError;
use hyper::method::Method;
use hyper::mime::{Mime, TopLevel, SubLevel};
@ -167,6 +167,16 @@ reason: \"certificate verify failed\" }]";
req.headers_mut().set(host);
if !req.headers().has::<Accept>() {
let accept = Accept(vec![
qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_string()), vec![])),
QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), Quality(900u16)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), Quality(800u16)),
]);
req.headers_mut().set(accept);
}
let (tx, rx) = channel();
cookies_chan.send(ControlMsg::GetCookiesForUrl(url.clone(), tx, CookieSource::HTTP)).unwrap();
if let Some(cookie_list) = rx.recv().unwrap() {