fix crash at setting empty values to HTTP proxies
with this patch `https_proxy=` and `http_proxy=` will work well.
This commit is contained in:
parent
b68624f2f3
commit
d47482fcd9
1 changed files with 10 additions and 6 deletions
16
src/main.rs
16
src/main.rs
|
@ -59,15 +59,19 @@ fn create_http_client(args: &AppArgs) -> Result<Client, reqwest::Error> {
|
|||
.default_headers(header_map);
|
||||
|
||||
if let Ok(var) = env::var("https_proxy").or_else(|_| env::var("HTTPS_PROXY")) {
|
||||
let proxy = Proxy::https(&var)
|
||||
.expect("Could not set HTTPS proxy. Please check $https_proxy env var");
|
||||
builder = builder.proxy(proxy);
|
||||
if !var.is_empty() {
|
||||
let proxy = Proxy::https(&var)
|
||||
.expect("Could not set HTTPS proxy. Please check $https_proxy env var");
|
||||
builder = builder.proxy(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(var) = env::var("http_proxy").or_else(|_| env::var("HTTP_PROXY")) {
|
||||
let proxy =
|
||||
Proxy::http(&var).expect("Could not set HTTP proxy. Please check $http_proxy env var");
|
||||
builder = builder.proxy(proxy);
|
||||
if !var.is_empty() {
|
||||
let proxy = Proxy::http(&var)
|
||||
.expect("Could not set HTTP proxy. Please check $http_proxy env var");
|
||||
builder = builder.proxy(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
builder.build()
|
||||
|
|
Loading…
Reference in a new issue