Skip to content

Commit

Permalink
enable TCP_NODELAY by default.
Browse files Browse the repository at this point in the history
Most of the browsers and clients enable the option TCP_NODELAY by
default to improve the performance.
  • Loading branch information
benoitc committed Apr 14, 2014
1 parent 28ef39a commit 4dae3f8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/hackney_connect.erl
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,24 @@ do_connect(Host, Port, Transport, #client{options=Opts,
ConnectOpts0
end,

ConnectOpts2 = case lists:keyfind(nodelay, 1, ConnectOpts1) of
false -> [{nodelay, true} | ConnectOpts1];
_ -> ConnectOpts1
end,

ConnectOpts = case {Transport, proplists:get_value(ssl_options, Opts)} of
{hackney_ssl_transport, undefined} ->
case proplists:get_value(insecure, Opts) of
true ->
ConnectOpts1 ++ [{verify, verify_none},
ConnectOpts2 ++ [{verify, verify_none},
{reuse_sessions, true}];
_ ->
ConnectOpts1
ConnectOpts2
end;
{hackney_ssl_transport, SslOpts} ->
ConnectOpts1 ++ SslOpts;
ConnectOpts2 ++ SslOpts;
{_, _} ->
ConnectOpts1
ConnectOpts2
end,

case Transport:connect(Host, Port, ConnectOpts, ConnectTimeout) of
Expand Down

0 comments on commit 4dae3f8

Please sign in to comment.