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:
parent
292039362a
commit
fbfec873f6
5 changed files with 79 additions and 6 deletions
|
@ -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}.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue