[pbs-devel] [PATCH proxmox 1/4] http: sync: set user-agent via ureq agent

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Mar 3 12:39:21 CET 2023


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 <f.gruenbichler at proxmox.com>
---
 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 41b9c79..9465d8e 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<ureq::Agent, Error> {
         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()?)?);
         }
-- 
2.30.2






More information about the pbs-devel mailing list