0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

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.
This commit is contained in:
Loïc Hoguin 2018-11-15 10:11:36 +01:00
parent 292039362a
commit fbfec873f6
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
5 changed files with 79 additions and 6 deletions

View file

@ -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}.