From d69fee254aecf9b4ce2286b00e32bfdfa8a23faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 3 Mar 2023 12:39:21 +0100 Subject: [PATCH] http: sync: set user-agent via ureq agent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this allows us to slim down our code, and once https://github.com/algesten/ureq/pull/597 is merged upstream (and/or we update to a version containing the fix) it also means the custom user agent is used for requests to the proxy host, if one is configured. Signed-off-by: Fabian Grünbichler --- proxmox-http/src/client/sync.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proxmox-http/src/client/sync.rs b/proxmox-http/src/client/sync.rs index 41b9c79c..9465d8e1 100644 --- a/proxmox-http/src/client/sync.rs +++ b/proxmox-http/src/client/sync.rs @@ -22,6 +22,14 @@ 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), + ); + if let Some(proxy_config) = &self.options.proxy_config { builder = builder.proxy(ureq::Proxy::new(proxy_config.to_proxy_string()?)?); }