@@ -700,20 +700,18 @@ Sets options to be used for subsequent requests.
700700 DomainDesc :: string (),
701701 HostName :: string ().
702702set_options (Options , Profile ) when is_atom (Profile ) orelse is_pid (Profile ) ->
703- IsInetsRunning = [Application || {inets , _ , _ } = Application <- application :which_applications ()] =/= [],
704- case IsInetsRunning of
705- true ->
706- {ok , IpFamily } = get_option (ipfamily , Profile ),
707- {ok , UnixSock } = get_option (unix_socket , Profile ),
708- case validate_options (Options , IpFamily , UnixSock ) of
709- {ok , Opts } ->
710- httpc_manager :set_options (Opts , profile_name (Profile ));
711- Error ->
712- Error
713- end ;
714- _ ->
715- {error , inets_not_started }
716- end .
703+ maybe
704+ {ok , CurrOpts } ?= get_options ([ipfamily , unix_socket ], Profile ),
705+ IpFamily = proplists :get_value (ipfamily , CurrOpts ),
706+ UnixSock = proplists :get_value (unix_socket , CurrOpts ),
707+ {ok , Opts } ?= validate_options (Options , IpFamily , UnixSock ),
708+ try
709+ httpc_manager :set_options (Opts , profile_name (Profile ))
710+ catch
711+ exit :{noproc , _ } ->
712+ {error , inets_not_started }
713+ end
714+ end .
717715
718716-doc false .
719717-spec set_option (atom (), term ()) -> ok | {error , term ()}.
0 commit comments