@@ -62,9 +62,9 @@ ensure_http_client_started(Id, ProxyOptions) ->
6262 root -> root ;
6363 _ -> binary_to_atom (Id )
6464 end ,
65- rabbit_log :debug (" Starting http client ~p " , [Profile ]),
65+ rabbit_log :debug (" Starting http client ~p ... " , [Profile ]),
6666 case inets :start (httpc , [{profile , Profile }]) of
67- ok ->
67+ { ok , _ } ->
6868 HttpProxyOptions = map_proxy_to_httpc_option (ProxyOptions ),
6969 case ensure_http_proxy_options_if_any (Profile , HttpProxyOptions ) of
7070 ok -> {ok , Profile };
@@ -73,23 +73,21 @@ ensure_http_client_started(Id, ProxyOptions) ->
7373 {error , {already_started , _ }} ->
7474 rabbit_log :debug (" Already started http client ~p " , [Profile ]),
7575 {ok , Profile };
76- Error -> Error
76+ Error ->
77+ rabbit_log :error (" Failed to start httpc client: ~p " , [Error ]),
78+ Error
7779 end .
7880ensure_http_proxy_options_if_any (_Profile , []) ->
7981 ok ;
80- ensure_http_proxy_options_if_any (Profile , HttpProxyOptions ) ->
81- case httpc :get_options ([proxy ]) of
82- {ok , _ } -> ok ;
83- {error , _ } ->
84- rabbit_log :debug (" Setting Proxy options to http client ~p " , [Profile ]),
85- case httpc :set_options (HttpProxyOptions , Profile ) of
86- ok ->
87- rabbit_log :debug (" SetOptions ~p on http client ~p " ,
88- [HttpProxyOptions , Profile ]),
89- ok ;
90- {error , _ } = Error -> Error
91- end
82+ ensure_http_proxy_options_if_any (Profile , HttpProxyOptions ) ->
83+ case httpc :set_options (HttpProxyOptions , Profile ) of
84+ ok ->
85+ rabbit_log :debug (" Successfully set_options ~p on http client ~p " ,
86+ [HttpProxyOptions , Profile ]),
87+ ok ;
88+ {error , _ } = Error -> Error
9289 end .
90+
9391http_post (Id , URL , Header , Type , Body , HTTPOptions , ProxyOptions ) ->
9492 http_request (Id , post , {URL , Header , Type , Body }, HTTPOptions , ProxyOptions ).
9593http_get (Id , URL , HTTPOptions , ProxyOptions ) ->
@@ -470,33 +468,33 @@ lookup_root_oauth_provider() ->
470468 authorization_endpoint = get_env (authorization_endpoint ),
471469 end_session_endpoint = get_env (end_session_endpoint ),
472470 ssl_options = extract_ssl_options_as_list (Map ),
473- proxy_options = extract_proxy_options (Map )
471+ proxy_options = extract_proxy_options (get_env ( proxy , []) )
474472 }.
475473
476474-spec extract_proxy_options (#{atom () => any ()}|list ()) -> proxy_options () | undefined .
477475extract_proxy_options (List ) when is_list (List ) ->
478- case {proplists :get_value (proxy_host , List , undefined ),
479- proplists :get_value (proxy_port , List , 0 )} of
476+ case {proplists :get_value (host , List , undefined ),
477+ proplists :get_value (port , List , 0 )} of
480478 {undefined , _ } -> undefined ;
481479 {_ , 0 } -> undefined ;
482480 {H , P } ->
483481 # proxy_options {
484482 host = H ,
485483 port = P ,
486- username = proplists :get_value (proxy_username , List , undefined ),
487- password = proplists :get_value (proxy_password , List , undefined )
484+ username = proplists :get_value (username , List , undefined ),
485+ password = proplists :get_value (password , List , undefined )
488486 }
489487 end ;
490488extract_proxy_options (Map ) ->
491- case {maps :get (proxy_host , Map , undefined ), maps :get (proxy_port , Map , 0 )} of
489+ case {maps :get (host , Map , undefined ), maps :get (port , Map , 0 )} of
492490 {undefined , _ } -> undefined ;
493491 {_ , 0 } -> undefined ;
494492 {H , P } ->
495493 # proxy_options {
496494 host = H ,
497495 port = P ,
498- username = maps :get (proxy_username , Map , undefined ),
499- password = maps :get (proxy_password , Map , undefined )
496+ username = maps :get (username , Map , undefined ),
497+ password = maps :get (password , Map , undefined )
500498 }
501499 end .
502500
@@ -713,7 +711,7 @@ map_to_oauth_provider(PropList) when is_list(PropList) ->
713711 extract_ssl_options_as_list (maps :from_list (
714712 proplists :get_value (https , PropList , []))),
715713 proxy_options =
716- extract_proxy_options (PropList )
714+ extract_proxy_options (proplists : get_value ( proxy , PropList , []) )
717715 }.
718716map_to_access_token_response (Code , Reason , Headers , Body ) ->
719717 case decode_body (proplists :get_value (" content-type" , Headers , ? CONTENT_JSON ), Body ) of
0 commit comments