http: sync: set user-agent via ureq agent
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@proxmox.com>
This commit is contained in:
parent
5df815f660
commit
d69fee254a
@ -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()?)?);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user