From 216f84cf92caebdaa3efc6dfaa8c65766f66e8db Mon Sep 17 00:00:00 2001 From: shakugan Date: Thu, 5 May 2016 04:03:33 +0000 Subject: [PATCH 1/2] sock options ignored on ssl --- src/ibrowse_http_client.erl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ibrowse_http_client.erl b/src/ibrowse_http_client.erl index 92ac431..c98be2a 100644 --- a/src/ibrowse_http_client.erl +++ b/src/ibrowse_http_client.erl @@ -565,7 +565,21 @@ do_connect(Host, Port, Options, #state{is_ssl = true, use_proxy = false, ssl_options = SSLOptions}, Timeout) -> - ssl:connect(Host, Port, get_sock_options(Host, Options, SSLOptions), Timeout); + Socks5Host = get_value(socks5_host, Options, undefined), + Sock_options = get_sock_options(Host, Options, []), + Conn = case Socks5Host of + undefined -> + gen_tcp:connect(Host, Port, Sock_options, Timeout); + _ -> + catch ibrowse_socks5:connect(Host, Port, Options, Sock_options, Timeout) + end, + case Conn of + {ok, Sock} -> + ssl:connect(Sock, SSLOptions); + _ -> + error + end; + do_connect(Host, Port, Options, _State, Timeout) -> Socks5Host = get_value(socks5_host, Options, undefined), Sock_options = get_sock_options(Host, Options, []), From 2bf69b3955b2d81cca1786c37d273ee7936abcf9 Mon Sep 17 00:00:00 2001 From: shakugan Date: Fri, 6 May 2016 11:32:27 +0000 Subject: [PATCH 2/2] call ssl:connect/3 with connect_timeout param Conn_timeout = get_value(connect_timeout, Options, Timeout), case do_connect(Host_1, Port_1, Options, State_2, Conn_timeout) of --- src/ibrowse_http_client.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ibrowse_http_client.erl b/src/ibrowse_http_client.erl index c98be2a..a4a0963 100644 --- a/src/ibrowse_http_client.erl +++ b/src/ibrowse_http_client.erl @@ -575,7 +575,7 @@ do_connect(Host, Port, Options, #state{is_ssl = true, end, case Conn of {ok, Sock} -> - ssl:connect(Sock, SSLOptions); + ssl:connect(Sock, SSLOptions, Timeout); _ -> error end;