diff options
author | Loïc Hoguin <[email protected]> | 2020-08-26 13:45:34 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2020-09-21 15:51:58 +0200 |
commit | 3de0604eec218996dad4db59c0cc96092cd7e0e7 (patch) | |
tree | 01a4dedc50b6f5bc5a88f15764f4df6a4bcdac31 /src/gun_socks.erl | |
parent | 96e36a877fe79362c829492f71d532541ca857d7 (diff) | |
download | gun-3de0604eec218996dad4db59c0cc96092cd7e0e7.tar.gz gun-3de0604eec218996dad4db59c0cc96092cd7e0e7.tar.bz2 gun-3de0604eec218996dad4db59c0cc96092cd7e0e7.zip |
Refactor protocol handling via gun_protocols
Diffstat (limited to 'src/gun_socks.erl')
-rw-r--r-- | src/gun_socks.erl | 9 |
1 files changed, 2 insertions, 7 deletions
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}] |