Browse Source

Add a user-agent header (#605)

remotes/origin/add-with-shims
Gal Schlezinger 3 years ago committed by GitHub
parent
commit
8d30f74a73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/http.rs

8
src/http.rs

@ -2,9 +2,15 @@ @@ -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<Response, Error> {
reqwest::blocking::get(url)
Client::new()
.get(url)
// Some sites require a user agent.
.header("User-Agent", concat!("fnm ", env!("CARGO_PKG_VERSION")))
.send()
}

Loading…
Cancel
Save