aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/resp_h.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-09-13 14:20:04 +0200
committerLoïc Hoguin <[email protected]>2019-09-14 18:21:05 +0200
commit49af57d546b5e2fd5aaa9fcd43d09060b9682c5a (patch)
treea59b73e1039fe33081491bf2a55621a7d2563356 /test/handlers/resp_h.erl
parent4427108b69fcd1e6a8233a217fa0e99d0564b714 (diff)
downloadcowboy-49af57d546b5e2fd5aaa9fcd43d09060b9682c5a.tar.gz
cowboy-49af57d546b5e2fd5aaa9fcd43d09060b9682c5a.tar.bz2
cowboy-49af57d546b5e2fd5aaa9fcd43d09060b9682c5a.zip
Implement backpressure on cowboy_req:stream_body
This should limit the amount of memory that Cowboy is using when a handler is sending data much faster than the network. The new max_stream_buffer_size is a soft limit and only has an effect when the cowboy_stream_h handler is used.
Diffstat (limited to 'test/handlers/resp_h.erl')
-rw-r--r--test/handlers/resp_h.erl5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl
index 5e5e766..19405db 100644
--- a/test/handlers/resp_h.erl
+++ b/test/handlers/resp_h.erl
@@ -221,6 +221,11 @@ do(<<"stream_body">>, Req0, Opts) ->
cowboy_req:stream_body(<<"world">>, nofin, Req),
cowboy_req:stream_body(<<"!">>, fin, Req),
{ok, Req, Opts};
+ <<"loop">> ->
+ Req = cowboy_req:stream_reply(200, Req0),
+ _ = [cowboy_req:stream_body(<<0:1000000/unit:8>>, nofin, Req)
+ || _ <- lists:seq(1, 32)],
+ {ok, Req, Opts};
<<"nofin">> ->
Req = cowboy_req:stream_reply(200, Req0),
cowboy_req:stream_body(<<"Hello world!">>, nofin, Req),