aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-09-20 16:22:53 +0200
committerLoïc Hoguin <[email protected]>2019-09-22 16:46:44 +0200
commit07e79aa3a70546fe4419b94cbf41c38a6eb039a1 (patch)
tree017d06819a79254c19dfafee8a2d0410be02b466 /src/gun_http.erl
parent53f0888993d7bb464c094ada645b075e43560403 (diff)
downloadgun-07e79aa3a70546fe4419b94cbf41c38a6eb039a1.tar.gz
gun-07e79aa3a70546fe4419b94cbf41c38a6eb039a1.tar.bz2
gun-07e79aa3a70546fe4419b94cbf41c38a6eb039a1.zip
Always switch_protocol
When doing a CONNECT from http to http or from socks to socks we may want to use different configuration options. Switching the protocol explicitly helps us achieve that. It will also signal through events that a protocol switch occurred.
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r--src/gun_http.erl11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 85fd2c4..44575bf 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -313,14 +313,9 @@ handle_head(Data, State=#http_state{version=ClientVersion, content_handlers=Hand
{[{origin, <<"https">>, NewHost, NewPort, connect},
{tls_handshake, HandshakeEvent, Protocols}], EvHandlerState1};
_ ->
- case Protocols of
- [http] ->
- {[{state, State2},
- {origin, <<"http">>, NewHost, NewPort, connect}], EvHandlerState1};
- [http2] ->
- {[{origin, <<"http">>, NewHost, NewPort, connect},
- {switch_protocol, http2}], EvHandlerState1}
- end
+ [Protocol] = Protocols,
+ {[{origin, <<"http">>, NewHost, NewPort, connect},
+ {switch_protocol, Protocol}], EvHandlerState1}
end;
{_, _} when Status >= 100, Status =< 199 ->
ReplyTo ! {gun_inform, self(), stream_ref(StreamRef), Status, Headers},