diff options
author | Loïc Hoguin <[email protected]> | 2019-07-26 12:35:38 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-07-26 12:36:55 +0200 |
commit | e4df3bb7c726571640c2799bc7a6fbb687b3bdae (patch) | |
tree | 1f044ea876852c876846a9d518c97e35cb535e53 /src/gun_http.erl | |
parent | c2ba2258a0020d82faa3e79162f05fc67d61b53e (diff) | |
download | gun-e4df3bb7c726571640c2799bc7a6fbb687b3bdae.tar.gz gun-e4df3bb7c726571640c2799bc7a6fbb687b3bdae.tar.bz2 gun-e4df3bb7c726571640c2799bc7a6fbb687b3bdae.zip |
Add tls_handshake events for CONNECT through TLS proxies
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r-- | src/gun_http.erl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl index 113de0d..68f9e7d 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -289,14 +289,22 @@ handle_head(Data, State=#http_state{socket=Socket, transport=Transport, #{transport := tls} when Transport =:= gun_tls -> TLSOpts = maps:get(tls_opts, Destination, []), TLSTimeout = maps:get(tls_handshake_timeout, Destination, infinity), + HandshakeEvent = #{ + stream_ref => RealStreamRef, + reply_to => ReplyTo, + socket => Socket, + tls_opts => TLSOpts, + timeout => TLSTimeout + }, + EvHandlerState = EvHandler:tls_handshake_start(HandshakeEvent, EvHandlerState1), {ok, ProxyPid} = gun_tls_proxy:start_link(NewHost, NewPort, - TLSOpts, TLSTimeout, Socket, gun_tls), + TLSOpts, TLSTimeout, Socket, gun_tls, HandshakeEvent), %% In this case the switch_protocol is delayed and is handled by %% a message sent from gun_tls_proxy once the connection is established, %% and handled by the gun module directly. {[{state, State2#http_state{socket=ProxyPid, transport=gun_tls_proxy}}, {origin, <<"https">>, NewHost, NewPort, connect}, - {switch_transport, gun_tls_proxy, ProxyPid}], EvHandlerState1}; + {switch_transport, gun_tls_proxy, ProxyPid}], EvHandlerState}; #{transport := tls} -> TLSOpts = maps:get(tls_opts, Destination, []), TLSTimeout = maps:get(tls_handshake_timeout, Destination, infinity), |