Fix #53 by setting the HTTP user agent string to the latest Firefox ESR.

This commit is contained in:
Rowan Lewis 2018-03-18 11:57:41 +01:00
parent 2457e95f0e
commit 7696014545

View File

@ -6,7 +6,7 @@ use url::Url;
use hyper::{Client, Method, Request, Response, StatusCode, Uri}; use hyper::{Client, Method, Request, Response, StatusCode, Uri};
use hyper::client::HttpConnector; use hyper::client::HttpConnector;
use hyper::header::{ETag, EntityTag, HttpDate, IfModifiedSince, IfNoneMatch, LastModified, use hyper::header::{ETag, EntityTag, HttpDate, IfModifiedSince, IfNoneMatch, LastModified,
Location}; Location, UserAgent};
use hyper_tls::HttpsConnector; use hyper_tls::HttpsConnector;
// use futures::future::ok; // use futures::future::ok;
@ -253,6 +253,12 @@ impl Source {
let uri = Uri::from_str(self.uri()).unwrap(); let uri = Uri::from_str(self.uri()).unwrap();
let mut req = Request::new(Method::Get, uri); let mut req = Request::new(Method::Get, uri);
// Set the user agent as a fix for issue #53
// TODO: keep this in sync with tor-browser releases
req.headers_mut().set(UserAgent::new(
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0",
));
if !ignore_etags { if !ignore_etags {
if let Some(foo) = self.http_etag() { if let Some(foo) = self.http_etag() {
req.headers_mut().set(IfNoneMatch::Items(vec![ req.headers_mut().set(IfNoneMatch::Items(vec![