From 76960145459e89a5e18de651917d946fde0dc23d Mon Sep 17 00:00:00 2001 From: Rowan Lewis Date: Sun, 18 Mar 2018 11:57:41 +0100 Subject: [PATCH] Fix #53 by setting the HTTP user agent string to the latest Firefox ESR. --- hammond-data/src/models/source.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hammond-data/src/models/source.rs b/hammond-data/src/models/source.rs index c8d77e1..74c155f 100644 --- a/hammond-data/src/models/source.rs +++ b/hammond-data/src/models/source.rs @@ -6,7 +6,7 @@ use url::Url; use hyper::{Client, Method, Request, Response, StatusCode, Uri}; use hyper::client::HttpConnector; use hyper::header::{ETag, EntityTag, HttpDate, IfModifiedSince, IfNoneMatch, LastModified, - Location}; + Location, UserAgent}; use hyper_tls::HttpsConnector; // use futures::future::ok; @@ -253,6 +253,12 @@ impl Source { let uri = Uri::from_str(self.uri()).unwrap(); 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 let Some(foo) = self.http_etag() { req.headers_mut().set(IfNoneMatch::Items(vec![