aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/sse_clock_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 /test/handlers/sse_clock_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 'test/handlers/sse_clock_h.erl')
-rw-r--r--test/handlers/sse_clock_h.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/handlers/sse_clock_h.erl b/test/handlers/sse_clock_h.erl
index 8c18ac5..dcc7c3f 100644
--- a/test/handlers/sse_clock_h.erl
+++ b/test/handlers/sse_clock_h.erl
@@ -15,6 +15,11 @@ init(Req, State) ->
info(timeout, Req, State) ->
erlang:send_after(1000, self(), timeout),
cowboy_req:stream_events(#{
- data => cowboy_clock:rfc1123()
+ data => data(State)
}, nofin, Req),
{ok, Req, State}.
+
+data(date) ->
+ cowboy_clock:rfc1123();
+data(Size) when is_integer(Size) ->
+ lists:duplicate(Size, $0).