From d47482fcd9208b1f5b54b9ed9afc2af7af287251 Mon Sep 17 00:00:00 2001 From: rhysd Date: Mon, 20 Jan 2020 17:17:24 +0900 Subject: [PATCH] fix crash at setting empty values to HTTP proxies with this patch `https_proxy=` and `http_proxy=` will work well. --- src/main.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 47a7937..1403b73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,15 +59,19 @@ fn create_http_client(args: &AppArgs) -> Result { .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()