From f1ac453b9ee9fb93ccb468fb2da1fceac1368e0a Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Mon, 20 Feb 2017 14:51:56 -0600 Subject: [PATCH] (GH-605) Use Proxy From Environment Vars If `http_proxy`/`https_proxy` are set in environment variables, use those for Chocolatey automatically. If `no_proxy` is set, then use it for the proxy bypass list. --- .../infrastructure.app/configuration/EnvironmentSettings.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/chocolatey/infrastructure.app/configuration/EnvironmentSettings.cs b/src/chocolatey/infrastructure.app/configuration/EnvironmentSettings.cs index 8a1cf96f9..9e63a8144 100644 --- a/src/chocolatey/infrastructure.app/configuration/EnvironmentSettings.cs +++ b/src/chocolatey/infrastructure.app/configuration/EnvironmentSettings.cs @@ -87,6 +87,11 @@ public static void set_environment_variables(ChocolateyConfiguration config) Environment.SetEnvironmentVariable("chocolateyRequestTimeout", config.WebRequestTimeoutSeconds.to_string() + "000"); Environment.SetEnvironmentVariable("chocolateyResponseTimeout", config.CommandExecutionTimeoutSeconds.to_string() + "000"); + + if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("https_proxy"))) Environment.SetEnvironmentVariable("chocolateyProxyLocation", Environment.GetEnvironmentVariable("https_proxy")); + if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("http_proxy")) && string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("chocolateyProxyLocation"))) Environment.SetEnvironmentVariable("chocolateyProxyLocation", Environment.GetEnvironmentVariable("http_proxy")); + if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("no_proxy"))) Environment.SetEnvironmentVariable("chocolateyProxyBypassList", Environment.GetEnvironmentVariable("no_proxy")); + if (!string.IsNullOrWhiteSpace(config.Proxy.Location)) { var proxyCreds = string.Empty;