diff options
author | Loïc Hoguin <[email protected]> | 2019-09-24 19:18:35 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-09-24 19:28:48 +0200 |
commit | d9a970be90d0105af215531d74809878f9c21338 (patch) | |
tree | eb891e8c9373dee9f7353a9920aaf25f6b2f2570 /src/gun_http.erl | |
parent | a18ca0ae8ff76594c7b629f4340adab0a30954c4 (diff) | |
download | gun-d9a970be90d0105af215531d74809878f9c21338.tar.gz gun-d9a970be90d0105af215531d74809878f9c21338.tar.bz2 gun-d9a970be90d0105af215531d74809878f9c21338.zip |
Add auto-ping to Websocket and a silence_pings option
The auto-ping will at regular interval send a ping frame.
The silence_pings option defaults to true. It can be set
to false when the user needs to receive ping/pong frames.
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r-- | src/gun_http.erl | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl index 87b50c8..f27563e 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -25,7 +25,7 @@ -export([update_flow/4]). -export([closing/4]). -export([close/4]). --export([keepalive/1]). +-export([keepalive/3]). -export([headers/11]). -export([request/12]). -export([data/7]). @@ -473,14 +473,14 @@ close_streams([#stream{ref=StreamRef, reply_to=ReplyTo}|Tail], Reason) -> close_streams(Tail, Reason). %% We don't send a keep-alive when a CONNECT request was initiated. -keepalive(State=#http_state{streams=[#stream{ref={connect, _, _}}]}) -> - State; +keepalive(State=#http_state{streams=[#stream{ref={connect, _, _}}]}, _, EvHandlerState) -> + {State, EvHandlerState}; %% We can only keep-alive by sending an empty line in-between streams. -keepalive(State=#http_state{socket=Socket, transport=Transport, out=head}) -> +keepalive(State=#http_state{socket=Socket, transport=Transport, out=head}, _, EvHandlerState) -> Transport:send(Socket, <<"\r\n">>), - State; -keepalive(State) -> - State. + {State, EvHandlerState}; +keepalive(State, _, EvHandlerState) -> + {State, EvHandlerState}. headers(State=#http_state{opts=Opts, out=head}, StreamRef, ReplyTo, Method, Host, Port, Path, Headers, |