aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZandra <[email protected]>2015-12-01 16:23:38 +0100
committerZandra <[email protected]>2015-12-01 16:23:38 +0100
commitb78c67a0e833abb1a43afcc016a2ab0436c08d2d (patch)
treed324f6be5dc17ec29a67a92041051040438859e3
parent552818fd16f1a842e5d206d43bb442de685356da (diff)
parent8391c2717200ce001684c53aca30ad64487cd281 (diff)
downloadotp-b78c67a0e833abb1a43afcc016a2ab0436c08d2d.tar.gz
otp-b78c67a0e833abb1a43afcc016a2ab0436c08d2d.tar.bz2
otp-b78c67a0e833abb1a43afcc016a2ab0436c08d2d.zip
Merge branch 'scrapinghub/sni_with_connect' into maint
* scrapinghub/sni_with_connect: inets: SNI to be passed with requests through CONNECT OTP-12985
-rw-r--r--lib/inets/src/http_client/httpc_handler.erl15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl
index e6dcfee818..d1c52dcc78 100644
--- a/lib/inets/src/http_client/httpc_handler.erl
+++ b/lib/inets/src/http_client/httpc_handler.erl
@@ -1827,11 +1827,13 @@ host_header(_, URI) ->
tls_upgrade(#state{status =
{ssl_tunnel,
#request{settings =
- #http_options{ssl = {_, TLSOptions} = SocketType},
- address = Address} = Request},
+ #http_options{ssl = {_, TLSOptions0} = SocketType},
+ address = {Host, _} = Address} = Request},
session = #session{socket = TCPSocket} = Session0,
options = Options} = State) ->
+ TLSOptions = maybe_add_sni(Host, TLSOptions0),
+
case ssl:connect(TCPSocket, TLSOptions) of
{ok, TLSSocket} ->
ClientClose = httpc_request:is_client_closing(Request#request.headers),
@@ -1862,6 +1864,15 @@ tls_upgrade(#state{status =
{stop, normal, State#state{request = Request}}
end.
+maybe_add_sni(Host, Options) ->
+ case http_util:is_hostname(Host) andalso
+ not lists:keymember(server_name_indication, 1, Options) of
+ true ->
+ [{server_name_indication, Host} | Options];
+ false ->
+ Options
+ end.
+
%% ---------------------------------------------------------------------
%% Session wrappers
%% ---------------------------------------------------------------------