diff --git a/Cargo.lock b/Cargo.lock index 7b52a32..6cd6da3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1494,7 +1494,7 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "site_icons" -version = "0.1.11" +version = "0.1.12" dependencies = [ "byteorder", "clap", diff --git a/Cargo.toml b/Cargo.toml index 572d2a7..746cf2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "site_icons" -version = "0.1.11" +version = "0.1.12" authors = ["Sam Denty "] edition = "2018" license = "GPL-3.0" diff --git a/src/icon_info.rs b/src/icon_info.rs index e2977be..73f7273 100644 --- a/src/icon_info.rs +++ b/src/icon_info.rs @@ -30,7 +30,10 @@ pub enum IconInfo { } impl IconInfo { - pub async fn load(url: Url, sizes: Option) -> Result> { + pub async fn load( + url: Url, + sizes: Option, + ) -> Result> { let sizes = sizes.as_ref().and_then(|s| IconSizes::from_str(s).ok()); let (mime, mut body): (_, Box) = match url.scheme() { diff --git a/src/lib.rs b/src/lib.rs index 9989f13..c993988 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,13 +38,18 @@ pub use icons::*; use once_cell::sync::Lazy; use reqwest::{ header::{HeaderMap, HeaderValue, USER_AGENT}, + redirect::Policy, Client, }; static CLIENT: Lazy = Lazy::new(|| { let mut headers = HeaderMap::new(); headers.insert(USER_AGENT, HeaderValue::from_str("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36").unwrap()); - Client::builder().default_headers(headers).build().unwrap() + Client::builder() + .default_headers(headers) + .redirect(Policy::limited(20)) + .build() + .unwrap() }); #[cfg(test)]