Skip to content

Commit

Permalink
add and no_proxy_env option to bypass proxy set in environment
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Sep 20, 2023
1 parent 47f56b6 commit c3064ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hackney.erl
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,16 @@ maybe_proxy(Transport, Host, Port, Options)
%% connect using a socks5 proxy
hackney_connect:connect(hackney_socks5, Host, Port, Options1, true);
_ ->
maybe_proxy_from_env(Transport, Host, Port, Options)
NoProxyEnv = proplists:get_value(
no_proxy_env, Options, application:get_env(hackney, no_proxy_env, false)
),
maybe_proxy_from_env(Transport, Host, Port, Options, NoProxyEnv)
end.

maybe_proxy_from_env(Transport, Host, Port, Options) ->
maybe_proxy_from_env(Transport, Host, Port, Options, true) ->
?report_debug("request without proxy", []),
hackney_connect:connect(Transport, Host, Port, Options, true);
maybe_proxy_from_env(Transport, Host, Port, Options, _) ->
case get_proxy_env() of
{ok, Url} ->
proxy_from_url(Url, Transport, Host, Port, Options);
Expand Down

0 comments on commit c3064ab

Please sign in to comment.