@@ -320,7 +320,8 @@ request(Method, #hackney_url{}=URL0, Headers0, Body, Options0) ->
320320 host = Host ,
321321 port = Port ,
322322 user = User ,
323- password = Password } = URL ,
323+ password = Password ,
324+ scheme = Scheme } = URL ,
324325
325326 Options = case User of
326327 <<>> ->
@@ -332,7 +333,7 @@ request(Method, #hackney_url{}=URL0, Headers0, Body, Options0) ->
332333
333334 Headers1 = hackney_headers_new :new (Headers0 ),
334335
335- case maybe_proxy (Transport , Host , Port , Options ) of
336+ case maybe_proxy (Transport , Scheme , Host , Port , Options ) of
336337 {ok , Ref , AbsolutePath } ->
337338 Request = make_request (
338339 Method , URL , Headers1 , Body , Options , AbsolutePath
@@ -615,7 +616,7 @@ make_request(Method, #hackney_url{}=URL, Headers, Body, _, _) ->
615616 {Method , FinalPath , Headers1 , Body }.
616617
617618
618- maybe_proxy (Transport , Host , Port , Options )
619+ maybe_proxy (Transport , Scheme , Host , Port , Options )
619620 when is_list (Host ), is_integer (Port ), is_list (Options ) ->
620621 case proplists :get_value (proxy , Options ) of
621622 Url when is_binary (Url ) orelse is_list (Url ) ->
@@ -671,14 +672,14 @@ maybe_proxy(Transport, Host, Port, Options)
671672 NoProxyEnv = proplists :get_value (
672673 no_proxy_env , Options , application :get_env (hackney , no_proxy_env , false )
673674 ),
674- maybe_proxy_from_env (Transport , Host , Port , Options , NoProxyEnv )
675+ maybe_proxy_from_env (Transport , Scheme , Host , Port , Options , NoProxyEnv )
675676 end .
676677
677- maybe_proxy_from_env (Transport , Host , Port , Options , true ) ->
678+ maybe_proxy_from_env (Transport , _Scheme , Host , Port , Options , true ) ->
678679 ? report_debug (" request without proxy" , []),
679680 hackney_connect :connect (Transport , Host , Port , Options , true );
680- maybe_proxy_from_env (Transport , Host , Port , Options , _ ) ->
681- case get_proxy_env () of
681+ maybe_proxy_from_env (Transport , Scheme , Host , Port , Options , _ ) ->
682+ case get_proxy_env (Scheme ) of
682683 {ok , Url } ->
683684 proxy_from_url (Url , Transport , Host , Port , Options );
684685 false ->
@@ -704,8 +705,10 @@ proxy_from_url(Url, Transport, Host, Port, Options) ->
704705 end
705706 end .
706707
707- get_proxy_env () ->
708- get_proxy_env (? PROXY_ENV_VARS ).
708+ get_proxy_env (https ) ->
709+ get_proxy_env (? HTTPS_PROXY_ENV_VARS );
710+ get_proxy_env (S ) when S =:= http ; S =:= http_unix ->
711+ get_proxy_env (? HTTP_PROXY_ENV_VARS );
709712
710713get_proxy_env ([Var | Rest ]) ->
711714 case os :getenv (Var ) of
0 commit comments