Skip to content

Commit

Permalink
Also use http_proxy if valid (#42)
Browse files Browse the repository at this point in the history
The change introduced in #24 could also be applied to the HTTP_PROXY environment variables.
  • Loading branch information
w0rd-driven committed Dec 10, 2022
1 parent b001ec2 commit 672a985
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/rustler_precompiled.ex
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,11 @@ defmodule RustlerPrecompiled do
{:ok, _} = Application.ensure_all_started(:inets)
{:ok, _} = Application.ensure_all_started(:ssl)

if proxy = System.get_env("HTTP_PROXY") || System.get_env("http_proxy") do
Logger.debug("Using HTTP_PROXY: #{proxy}")
%{host: host, port: port} = URI.parse(proxy)
proxy = System.get_env("HTTP_PROXY") || System.get_env("http_proxy")

with true <- is_binary(proxy),
%{host: host, port: port} when is_binary(host) and is_integer(port) <- URI.parse(proxy) do
Logger.debug("Using HTTP_PROXY: #{proxy}")
:httpc.set_options([{:proxy, {{String.to_charlist(host), port}, []}}])
end

Expand Down

0 comments on commit 672a985

Please sign in to comment.