Improve formatting
This commit is contained in:
parent
59c634f626
commit
50a508b596
@ -74,6 +74,11 @@ pub use feed::{Feed, FeedBuilder};
|
|||||||
pub use models::Save;
|
pub use models::Save;
|
||||||
pub use models::{Episode, EpisodeWidgetQuery, Podcast, PodcastCoverQuery, Source};
|
pub use models::{Episode, EpisodeWidgetQuery, Podcast, PodcastCoverQuery, Source};
|
||||||
|
|
||||||
|
// Set the user agent, See #53 for more
|
||||||
|
// Keep this in sync with Tor-browser releases
|
||||||
|
const USER_AGENT: &'static str =
|
||||||
|
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0";
|
||||||
|
|
||||||
/// [XDG Base Direcotory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) Paths.
|
/// [XDG Base Direcotory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) Paths.
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub mod xdg_dirs {
|
pub mod xdg_dirs {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ use errors::*;
|
|||||||
use feed::{Feed, FeedBuilder};
|
use feed::{Feed, FeedBuilder};
|
||||||
use models::{NewSource, Save};
|
use models::{NewSource, Save};
|
||||||
use schema::source;
|
use schema::source;
|
||||||
|
use USER_AGENT;
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
@ -215,24 +216,18 @@ 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
|
// Set the UserAgent cause ppl still seem to check it for some reason...
|
||||||
// TODO: keep this in sync with tor-browser releases
|
req.headers_mut().set(UserAgent::new(USER_AGENT));
|
||||||
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(etag) = self.http_etag() {
|
||||||
req.headers_mut()
|
let tag = vec![EntityTag::new(true, etag.to_owned())];
|
||||||
.set(IfNoneMatch::Items(vec![EntityTag::new(
|
req.headers_mut().set(IfNoneMatch::Items(tag));
|
||||||
true,
|
|
||||||
foo.to_owned(),
|
|
||||||
)]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(foo) = self.last_modified() {
|
if let Some(lmod) = self.last_modified() {
|
||||||
if let Ok(x) = foo.parse::<HttpDate>() {
|
if let Ok(date) = lmod.parse::<HttpDate>() {
|
||||||
req.headers_mut().set(IfModifiedSince(x));
|
req.headers_mut().set(IfModifiedSince(date));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user