Skip to content

Commit dc0b4f9

Browse files
authored
Treat empty proxy env vars as unset (#95)
1 parent 22048b0 commit dc0b4f9

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/elixir_make/downloader/httpc.ex

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ defmodule ElixirMake.Downloader.Httpc do
1212
{:ok, _} = Application.ensure_all_started(:ssl)
1313
{:ok, _} = Application.ensure_all_started(:public_key)
1414

15-
if proxy = System.get_env("HTTP_PROXY") || System.get_env("http_proxy") do
15+
if proxy = proxy_env(:http) do
1616
Mix.shell().info("Using HTTP_PROXY: #{proxy}")
1717
%{host: host, port: port} = URI.parse(proxy)
1818

1919
:httpc.set_options([{:proxy, {{String.to_charlist(host), port}, []}}])
2020
end
2121

22-
if proxy = System.get_env("HTTPS_PROXY") || System.get_env("https_proxy") do
22+
if proxy = proxy_env(:https) do
2323
Mix.shell().info("Using HTTPS_PROXY: #{proxy}")
2424
%{host: host, port: port} = URI.parse(proxy)
2525
:httpc.set_options([{:https_proxy, {{String.to_charlist(host), port}, []}}])
@@ -75,6 +75,16 @@ defmodule ElixirMake.Downloader.Httpc do
7575
end
7676
end
7777

78+
defp proxy_env(:http), do: get_env("HTTP_PROXY") || get_env("http_proxy")
79+
defp proxy_env(:https), do: get_env("HTTPS_PROXY") || get_env("https_proxy")
80+
81+
defp get_env(var) do
82+
case System.get_env(var) do
83+
"" -> nil
84+
value -> value
85+
end
86+
end
87+
7888
defp warn_no_cacerts do
7989
Mix.shell().error("""
8090
No certificate trust store was found.

0 commit comments

Comments
 (0)