aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_ws_h.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-08-02 14:30:08 +0200
committerLoïc Hoguin <[email protected]>2019-08-05 19:57:13 +0200
commit611f9a9b78cab4005892e13dffb7a2c8e44580ee (patch)
treed8d3fc407110ea12333ba122cf711326e82a7070 /src/gun_ws_h.erl
parent145b9af4bdbb85e2f83959ee8abaa4d9207a4529 (diff)
downloadgun-611f9a9b78cab4005892e13dffb7a2c8e44580ee.tar.gz
gun-611f9a9b78cab4005892e13dffb7a2c8e44580ee.tar.bz2
gun-611f9a9b78cab4005892e13dffb7a2c8e44580ee.zip
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.
Diffstat (limited to 'src/gun_ws_h.erl')
-rw-r--r--src/gun_ws_h.erl8
1 files changed, 4 insertions, 4 deletions
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}.