From 8d30f74a73051c37b44432f1d2f812780f9d867f Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Mon, 20 Dec 2021 11:42:26 +0200 Subject: [PATCH] Add a user-agent header (#605) --- src/http.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/http.rs b/src/http.rs index 32f8ef7..b5e3339 100644 --- a/src/http.rs +++ b/src/http.rs @@ -2,9 +2,15 @@ //! In the future, if we want to migrate to a different HTTP library, //! we can easily change this facade instead of multiple places in the crate. +use reqwest::blocking::Client; + pub type Error = reqwest::Error; pub type Response = reqwest::blocking::Response; pub fn get(url: &str) -> Result { - reqwest::blocking::get(url) + Client::new() + .get(url) + // Some sites require a user agent. + .header("User-Agent", concat!("fnm ", env!("CARGO_PKG_VERSION"))) + .send() }