From 35ee277a234a92add2f6244ad6f7ff3616b17ebe Mon Sep 17 00:00:00 2001 From: sigoden Date: Wed, 6 Nov 2024 06:46:29 +0800 Subject: feat: add config `user_agent` (#971) --- src/client/common.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/client') diff --git a/src/client/common.rs b/src/client/common.rs index 1275d0b..9c516c8 100644 --- a/src/client/common.rs +++ b/src/client/common.rs @@ -43,6 +43,9 @@ pub trait Client: Sync + Send { let timeout = extra.and_then(|v| v.connect_timeout).unwrap_or(10); let proxy = extra.and_then(|v| v.proxy.clone()); builder = set_proxy(builder, proxy.as_ref())?; + if let Some(user_agent) = self.global_config().read().user_agent.as_ref() { + builder = builder.user_agent(user_agent); + } let client = builder .connect_timeout(Duration::from_secs(timeout)) .build() -- cgit v1.2.3