Skip to content

Commit 4e3d912

Browse files
MarkoMinWhaileee
authored andcommitted
fix: rm which_applications in httpc:set_options/2
1 parent 88846fd commit 4e3d912

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

lib/inets/src/http_client/httpc.erl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -700,20 +700,18 @@ Sets options to be used for subsequent requests.
700700
DomainDesc :: string(),
701701
HostName :: string().
702702
set_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

Comments
 (0)