From 6a1be173a64c8a8eadc72798e7db23e5f03daed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 3 Mar 2023 12:39:23 +0100 Subject: [PATCH] http: sync: derive default user-agent from crate version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- proxmox-http/src/client/sync.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/proxmox-http/src/client/sync.rs b/proxmox-http/src/client/sync.rs index 228f839c..5a200e03 100644 --- a/proxmox-http/src/client/sync.rs +++ b/proxmox-http/src/client/sync.rs @@ -7,8 +7,6 @@ use http::Response; use crate::HttpClient; use crate::HttpOptions; -pub const DEFAULT_USER_AGENT_STRING: &str = "proxmox-sync-http-client/0.1"; - #[derive(Default)] /// Blocking HTTP client for usage with [`HttpClient`]. pub struct Client { @@ -23,12 +21,10 @@ impl Client { fn agent(&self) -> Result { let mut builder = ureq::AgentBuilder::new(); - builder = builder.user_agent( - self.options - .user_agent - .as_deref() - .unwrap_or(DEFAULT_USER_AGENT_STRING), - ); + builder = builder.user_agent(self.options.user_agent.as_deref().unwrap_or(&format!( + "proxmox-sync-http-client/{}", + env!("CARGO_PKG_VERSION") + ))); if let Some(proxy_config) = &self.options.proxy_config { builder = builder.proxy(ureq::Proxy::new(proxy_config.to_proxy_string()?)?);