Skip to content

Commit

Permalink
Fix manual address family connect_options
Browse files Browse the repository at this point in the history
  • Loading branch information
Kozlov Yakov committed Nov 7, 2018
1 parent 68e540b commit 84fb382
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/lhttpc_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ execute(From, Host, Port, Ssl, Path, Method, Hdrs0, Body, Options) ->
DefOptions = proplists:unfold(application:get_env(lhttpc, connect_options, [])),
DefTimeout = proplists:get_value(connect_timeout, DefOptions, infinity),
UserOptions = proplists:unfold(proplists:get_value(connect_options, Options, [])),
EffectiveTcpOptions = lists:ukeymerge(1,
EffectiveTcpOptions0 = lists:ukeymerge(1,
lists:ukeysort(1, UserOptions),
lists:ukeysort(1, DefOptions)
),
EffectiveTcpOptions = fix_inet_options(EffectiveTcpOptions0),
EffectiveOptions = case Ssl of
true ->
DefSslOptions = application:get_env(lhttpc, ssl_options, []),
Expand Down Expand Up @@ -956,3 +957,18 @@ is_ipv6_host(Host) ->
end
end
end.

%%------------------------------------------------------------------------------
%% @private
%%------------------------------------------------------------------------------
fix_inet_options(Options) ->
lists:filtermap(
fun ({AddressFamily, Bool}) when AddressFamily =:= inet;
AddressFamily =:= inet6;
AddressFamily =:= local ->
case Bool of
true -> {true, AddressFamily};
false -> false
end;
(Option) -> {true, Option}
end, Options).

0 comments on commit 84fb382

Please sign in to comment.