diff options
author | Brandon DeRosier <bdero@mit.edu> | 2015-03-27 21:49:15 -0400 |
---|---|---|
committer | Brandon DeRosier <bdero@mit.edu> | 2015-04-26 22:39:23 -0400 |
commit | 0a7a853a0129540c4211da5c1f81dbf7cc638712 (patch) | |
tree | 7e2af93ad171e1d2be84e07ba2db484f3d5ba46d | |
parent | f5d21faa8b9f95cee4128eca4b7fa5aa2389376b (diff) | |
download | servo-0a7a853a0129540c4211da5c1f81dbf7cc638712.tar.gz servo-0a7a853a0129540c4211da5c1f81dbf7cc638712.zip |
Add Accept header to HTTP loader
The value of the header is the same as that of Firefox 35.0.1:
`text/html, application/xhtml+xml, application/xml; q=0.9, */*; q=0.8`
Closes #5399
-rw-r--r-- | components/net/http_loader.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 0ac6980bb69..d069dfa622d 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -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() { |