From 3de0604eec218996dad4db59c0cc96092cd7e0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 26 Aug 2020 13:45:34 +0200 Subject: Refactor protocol handling via gun_protocols --- src/gun_socks.erl | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/gun_socks.erl') diff --git a/src/gun_socks.erl b/src/gun_socks.erl index b7a08b2..ce91f93 100644 --- a/src/gun_socks.erl +++ b/src/gun_socks.erl @@ -152,13 +152,8 @@ handle(<<5, 0, 0, Rest0/bits>>, #socks_state{ref=StreamRef, reply_to=ReplyTo, op {tls_handshake, HandshakeEvent, maps:get(protocols, Opts, [http2, http]), ReplyTo}]; _ -> [NewProtocol0] = maps:get(protocols, Opts, [http]), - NewProtocol = {Protocol0, _} = case {StreamRef, NewProtocol0} of - {undefined, {_, _}} -> NewProtocol0; - {undefined, P} -> {P, #{}}; - {_, {P, POpts}} -> {P, POpts#{stream_ref => StreamRef}}; - {_, P} -> {P, #{stream_ref => StreamRef}} - end, - Protocol = gun:protocol_handler(Protocol0), + NewProtocol = gun_protocols:add_stream_ref(NewProtocol0, StreamRef), + Protocol = gun_protocols:handler(NewProtocol), ReplyTo ! {gun_tunnel_up, self(), StreamRef, Protocol:name()}, [{origin, <<"http">>, NewHost, NewPort, socks5}, {switch_protocol, NewProtocol, ReplyTo}] -- cgit v1.2.3