From d3f8802514f829d1d1847730c43815571c7c48a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Wed, 16 Feb 2022 11:20:27 +1300 Subject: [PATCH] Add user agent to quickinstall stats report --- src/fetchers/quickinstall.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fetchers/quickinstall.rs b/src/fetchers/quickinstall.rs index e30563c5..beb2a1b2 100644 --- a/src/fetchers/quickinstall.rs +++ b/src/fetchers/quickinstall.rs @@ -8,6 +8,7 @@ use crate::{download, remote_exists, PkgFmt}; const BASE_URL: &str = "https://github.com/alsuren/cargo-quickinstall/releases/download"; const STATS_URL: &str = "https://warehouse-clerk-tmp.vercel.app/api/crate"; +const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); pub struct QuickInstall { package: String, @@ -61,7 +62,12 @@ impl QuickInstall { pub async fn report(&self) -> Result<(), anyhow::Error> { info!("Sending installation report to quickinstall (anonymous)"); - remote_exists(&self.stats_url(), Method::HEAD).await?; + reqwest::Client::builder() + .user_agent(USER_AGENT) + .build()? + .request(Method::HEAD, &self.stats_url()) + .send() + .await?; Ok(()) } }