Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/elixir_make/downloader/httpc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ defmodule ElixirMake.Downloader.Httpc do
{:ok, _} = Application.ensure_all_started(:ssl)
{:ok, _} = Application.ensure_all_started(:public_key)

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

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

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

defp proxy_env(:http), do: get_env("HTTP_PROXY") || get_env("http_proxy")
defp proxy_env(:https), do: get_env("HTTPS_PROXY") || get_env("https_proxy")

defp get_env(var) do
case System.get_env(var) do
"" -> nil
value -> value
end
end

defp warn_no_cacerts do
Mix.shell().error("""
No certificate trust store was found.
Expand Down
Loading