From 611f9a9b78cab4005892e13dffb7a2c8e44580ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 2 Aug 2019 14:30:08 +0200 Subject: Add flow control Flow control is disabled by default. The initial flow value must be set to enable it (either for the entire connection or on a per-request basis). Flow applies to all HTTP streams as well as Websocket. HTTP/2 pushed streams receive the same value as their originating stream. --- src/gun_ws_h.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gun_ws_h.erl') diff --git a/src/gun_ws_h.erl b/src/gun_ws_h.erl index 5ff0646..4859532 100644 --- a/src/gun_ws_h.erl +++ b/src/gun_ws_h.erl @@ -24,15 +24,15 @@ }). init(ReplyTo, StreamRef, _, _) -> - #state{reply_to=ReplyTo, stream_ref=StreamRef}. + {ok, #state{reply_to=ReplyTo, stream_ref=StreamRef}}. handle({fragment, nofin, _, Payload}, State=#state{frag_buffer=SoFar}) -> - State#state{frag_buffer= << SoFar/binary, Payload/binary >>}; + {ok, 0, State#state{frag_buffer= << SoFar/binary, Payload/binary >>}}; handle({fragment, fin, Type, Payload}, State=#state{reply_to=ReplyTo, stream_ref=StreamRef, frag_buffer=SoFar}) -> ReplyTo ! {gun_ws, self(), StreamRef, {Type, << SoFar/binary, Payload/binary >>}}, - State#state{frag_buffer= <<>>}; + {ok, 1, State#state{frag_buffer= <<>>}}; handle(Frame, State=#state{reply_to=ReplyTo, stream_ref=StreamRef}) -> ReplyTo ! {gun_ws, self(), StreamRef, Frame}, - State. + {ok, 1, State}. -- cgit v1.2.3