From 5e3a5337a34dcb09418d4f412b11ede4510e3ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 22 Apr 2019 13:40:07 +0200 Subject: Make gun_tls_proxy work for HTTP/2 connections --- src/gun_tls_proxy.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gun_tls_proxy.erl') diff --git a/src/gun_tls_proxy.erl b/src/gun_tls_proxy.erl index 8adb5b6..123a156 100644 --- a/src/gun_tls_proxy.erl +++ b/src/gun_tls_proxy.erl @@ -222,8 +222,13 @@ not_connected({call, _}, Msg={send, _}, State) -> not_connected(cast, Msg={setopts, _}, State) -> ?DEBUG_LOG("postpone ~0p state ~0p", [Msg, State]), {keep_state_and_data, postpone}; -not_connected(cast, Msg={connect_proc, {ok, Socket}}, State) -> +not_connected(cast, Msg={connect_proc, {ok, Socket}}, State=#state{owner_pid=OwnerPid}) -> ?DEBUG_LOG("msg ~0p state ~0p", [Msg, State]), + Protocol = case ssl:negotiated_protocol(Socket) of + {ok, <<"h2">>} -> gun_http2; + _ -> gun_http + end, + OwnerPid ! {connect_protocol, Protocol}, ok = ssl:setopts(Socket, [{active, true}]), {next_state, connected, State#state{proxy_socket=Socket}}; not_connected(cast, Msg={connect_proc, Error}, State) -> -- cgit v1.2.3