From 4b6e8b5ff8837a6ba1fb9e9faacd69ee0a8d27b0 Mon Sep 17 00:00:00 2001 From: Marko Mindek Date: Tue, 21 Oct 2025 01:04:59 +0200 Subject: [PATCH] fix: rm which_applications in httpc:set_options/2 --- lib/inets/src/http_client/httpc.erl | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/inets/src/http_client/httpc.erl b/lib/inets/src/http_client/httpc.erl index 50fa2ebe8318..a2917efaddb4 100644 --- a/lib/inets/src/http_client/httpc.erl +++ b/lib/inets/src/http_client/httpc.erl @@ -698,20 +698,18 @@ Sets options to be used for subsequent requests. DomainDesc :: string(), HostName :: uri_string:uri_string(). set_options(Options, Profile) when is_atom(Profile) orelse is_pid(Profile) -> - IsInetsRunning = [Application || {inets, _, _} = Application <- application:which_applications()] =/= [], - case IsInetsRunning of - true -> - {ok, IpFamily} = get_option(ipfamily, Profile), - {ok, UnixSock} = get_option(unix_socket, Profile), - case validate_options(Options, IpFamily, UnixSock) of - {ok, Opts} -> - httpc_manager:set_options(Opts, profile_name(Profile)); - Error -> - Error - end; - _ -> - {error, inets_not_started} - end. + maybe + {ok, CurrOpts} ?= get_options([ipfamily, unix_socket], Profile), + IpFamily = proplists:get_value(ipfamily, CurrOpts), + UnixSock = proplists:get_value(unix_socket, CurrOpts), + {ok, Opts} ?= validate_options(Options, IpFamily, UnixSock), + try + httpc_manager:set_options(Opts, profile_name(Profile)) + catch + exit:{noproc, _} -> + {error, inets_not_started} + end + end. -doc false. -spec set_option(atom(), term()) -> ok | {error, term()}.