On Mon, Mar 21, 2022 at 02:24:54PM +0100, Mira Limbeck wrote: > ureq has support for a HTTP proxy, but no support for HTTPS proxy yet. > > ureq doesn't query `all_proxy` and `ALL_PROXY` environment variables by > itself the way curl does. So set the proxy in code if any of the above > environment variables are set. > > Signed-off-by: Mira Limbeck <m.limb...@proxmox.com> > --- > src/http_client.rs | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/src/http_client.rs b/src/http_client.rs > index 5cceafb..a732a98 100644 > --- a/src/http_client.rs > +++ b/src/http_client.rs > @@ -40,9 +40,18 @@ pub enum Error { > } > > fn ureq_agent() -> Result<ureq::Agent, Error> { > - Ok(ureq::AgentBuilder::new() > - .tls_connector(Arc::new(native_tls::TlsConnector::new()?)) > - .build()) > + let mut agent = > + > ureq::AgentBuilder::new().tls_connector(Arc::new(native_tls::TlsConnector::new()?)); > + if let Ok(val) = std::env::var("all_proxy") {
Just add .or_else(|_| std::env::var("ALL_PROXY")) to the query instead of duplicating the body ;-) > + let proxy = ureq::Proxy::new(val).map_err(Box::new)?; > + agent = agent.proxy(proxy); > + } else if let Ok(val) = std::env::var("ALL_PROXY") { since this is identical code: > + let proxy = ureq::Proxy::new(val).map_err(Box::new)?; > + agent = agent.proxy(proxy); > + } > + > + > + Ok(agent.build()) > } > > /// > -- > 2.30.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel