Skip to content

Commit

Permalink
backport httpc:set_options fix to OTP-25.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Whaileee committed Dec 2, 2024
1 parent 114192b commit 4ad1570
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions lib/inets/src/http_client/httpc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,20 @@ set_options(Options) ->
DomainDesc :: string(),
HostName :: uri_string:uri_string().
set_options(Options, Profile) when is_atom(Profile) orelse is_pid(Profile) ->
maybe
{ok, IpFamily} ?= get_option(ipfamily, Profile),
{ok, UnixSock} ?= get_option(unix_socket, Profile),
{ok, Opts} ?= validate_options(Options, IpFamily, UnixSock),
httpc_manager:set_options(Opts, profile_name(Profile))
end.
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.

-spec set_option(atom(), term()) -> ok | {error, term()}.
set_option(Key, Value) ->
Expand Down
2 changes: 1 addition & 1 deletion lib/inets/test/httpc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ unix_domain_socket(Config) when is_list(Config) ->
invalid_ipfamily_unix_socket() ->
[{doc, "Test that httpc profile can't end up having invalid combination of ipfamily and unix_socket options"}].
invalid_ipfamily_unix_socket(Config) when is_list(Config) ->
Profile = ?profile(Config),
Profile = proplists:get_value(profile, Config, httpc:default_profile()),

ct:log("Using profile ~w", [Profile]),
{ok,[{unix_socket,?UNIX_SOCKET}, {ipfamily, local}]} =
Expand Down

0 comments on commit 4ad1570

Please sign in to comment.