From 37b771210f94b9b692d0417d79483b9927d46ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 22 Sep 2019 15:04:37 +0200 Subject: Document Socks support Also correct various Socks related types. This commit also adds a new gun:protocols/0 type as a simpler way of describing preferred protocols. The protocol/opts tuple is also documented. This commit also fixes an issue with the default value for the preferred protocols when using CONNECT over TLS. It was mistakenly not enabling http2 by default. --- src/gun_http.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gun_http.erl') diff --git a/src/gun_http.erl b/src/gun_http.erl index ce174ce..8860baa 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -301,7 +301,6 @@ handle_head(Data, State=#http_state{version=ClientVersion, content_handlers=Hand _ = end_stream(State#http_state{streams=[Stream|Tail]}), NewHost = maps:get(host, Destination), NewPort = maps:get(port, Destination), - Protocols = maps:get(protocols, Destination, [http]), case Destination of #{transport := tls} -> HandshakeEvent = #{ @@ -310,10 +309,11 @@ handle_head(Data, State=#http_state{version=ClientVersion, content_handlers=Hand tls_opts => maps:get(tls_opts, Destination, []), timeout => maps:get(tls_handshake_timeout, Destination, infinity) }, + Protocols = maps:get(protocols, Destination, [http2, http]), {[{origin, <<"https">>, NewHost, NewPort, connect}, {tls_handshake, HandshakeEvent, Protocols}], EvHandlerState1}; _ -> - [Protocol] = Protocols, + [Protocol] = maps:get(protocols, Destination, [http]), {[{origin, <<"http">>, NewHost, NewPort, connect}, {switch_protocol, Protocol}], EvHandlerState1} end; -- cgit v1.2.3