diff options
author | Loïc Hoguin <[email protected]> | 2018-11-15 10:11:36 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-11-15 10:11:36 +0100 |
commit | fbfec873f6026b858c3604d74d88470ce45f4296 (patch) | |
tree | 021fd12f5458d659e15a4bc7638b4dfd62a9df21 /test/handlers/compress_h.erl | |
parent | 292039362a6125dfd0a163d5b0a49b800bf80b11 (diff) | |
download | cowboy-fbfec873f6026b858c3604d74d88470ce45f4296.tar.gz cowboy-fbfec873f6026b858c3604d74d88470ce45f4296.tar.bz2 cowboy-fbfec873f6026b858c3604d74d88470ce45f4296.zip |
Add a compress_buffering option to cowboy_compress_h
Also changes the behavior to disable buffering by default, so
that the default works in all cases, including server-sent events.
Diffstat (limited to 'test/handlers/compress_h.erl')
-rw-r--r-- | test/handlers/compress_h.erl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/handlers/compress_h.erl b/test/handlers/compress_h.erl index 1509d82..ffea05f 100644 --- a/test/handlers/compress_h.erl +++ b/test/handlers/compress_h.erl @@ -50,6 +50,14 @@ init(Req0, State=stream_reply) -> cowboy_req:stream_body({sendfile, 0, Size, AppFile}, nofin, Req1), cowboy_req:stream_body(Data, nofin, Req1), cowboy_req:stream_body({sendfile, 0, Size, AppFile}, fin, Req1), + Req1; + <<"delayed">> -> + Req1 = cowboy_req:stream_reply(200, Req0), + cowboy_req:stream_body(<<"data: Hello!\r\n\r\n">>, nofin, Req1), + timer:sleep(1000), + cowboy_req:stream_body(<<"data: World!\r\n\r\n">>, nofin, Req1), + timer:sleep(1000), + cowboy_req:stream_body(<<"data: Closing!\r\n\r\n">>, fin, Req1), Req1 end, {ok, Req, State}. |