http_chunked.erl 413 B

123456789101112131415
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. -module(http_chunked).
  3. -export([init/2]).
  4. init(Req, Opts) ->
  5. Req2 = cowboy_req:chunked_reply(200, Req),
  6. %% Try an empty chunk to make sure the stream doesn't get closed.
  7. cowboy_req:chunk([<<>>], Req2),
  8. timer:sleep(100),
  9. cowboy_req:chunk("chunked_handler\r\n", Req2),
  10. timer:sleep(100),
  11. cowboy_req:chunk("works fine!", Req2),
  12. {ok, Req2, Opts}.