From d8e91eefa6ea9973f60657db05c85ec594aa7d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 26 Sep 2018 13:51:13 +0200 Subject: Don't send keep-alive while waiting for CONNECT responses Otherwise this can mess up the underlying protocol we will switch to, like TLS or HTTP/2. --- src/gun_http.erl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gun_http.erl') diff --git a/src/gun_http.erl b/src/gun_http.erl index c4291bc..e2b37d1 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -319,6 +319,9 @@ close_streams([#stream{ref=StreamRef, reply_to=ReplyTo}|Tail]) -> "The connection was lost."}}, close_streams(Tail). +%% We don't send a keep-alive when a CONNECT request was initiated. +keepalive(State=#http_state{streams=[#stream{ref={connect, _, _}}]}) -> + State; %% We can only keep-alive by sending an empty line in-between streams. keepalive(State=#http_state{socket=Socket, transport=Transport, out=head}) -> Transport:send(Socket, <<"\r\n">>), -- cgit v1.2.3