From 62013068cac2747605c9b4f724ef4238d442c2b5 Mon Sep 17 00:00:00 2001 From: asonix Date: Wed, 26 Jun 2024 13:29:42 -0500 Subject: [PATCH] Set user-agent from cargo metadata --- src/lib.rs | 4 +++- src/store/object_store.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 766a69f..93fdd69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1586,9 +1586,11 @@ fn build_client_config() -> rustls::ClientConfig { .with_no_client_auth() } +const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), " ", env!("CARGO_PKG_VERSION")); + fn build_client() -> Result { let client = reqwest::Client::builder() - .user_agent("pict-rs v0.5.0-main") + .user_agent(USER_AGENT) .use_preconfigured_tls(build_client_config()) .build() .map_err(UploadError::BuildClient)?; diff --git a/src/store/object_store.rs b/src/store/object_store.rs index c1d90fb..d9af3be 100644 --- a/src/store/object_store.rs +++ b/src/store/object_store.rs @@ -319,6 +319,7 @@ impl ObjectStore { let https = endpoint.scheme() == "https"; let client_options = object_store::ClientOptions::new() + .with_user_agent(reqwest::header::HeaderValue::from_static(crate::USER_AGENT)) .with_timeout(Duration::from_secs(client_timeout)) .with_allow_http(!https);