http_streamed.erl 377 B

1234567891011121314
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. -module(http_streamed).
  3. -export([init/2]).
  4. init(Req, Opts) ->
  5. Req2 = cowboy_req:set([{resp_state, waiting_stream}], Req),
  6. Req3 = cowboy_req:chunked_reply(200, Req2),
  7. timer:sleep(100),
  8. cowboy_req:chunk("streamed_handler\r\n", Req3),
  9. timer:sleep(100),
  10. cowboy_req:chunk("works fine!", Req3),
  11. {ok, Req3, Opts}.