http_chunked.erl 378 B

1234567891011121314151617
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. -module(http_chunked).
  3. -export([init/2]).
  4. -export([handle/2]).
  5. init(Req, Opts) ->
  6. {http, Req, Opts}.
  7. handle(Req, State) ->
  8. Req2 = cowboy_req:chunked_reply(200, Req),
  9. timer:sleep(100),
  10. cowboy_req:chunk("chunked_handler\r\n", Req2),
  11. timer:sleep(100),
  12. cowboy_req:chunk("works fine!", Req2),
  13. {ok, Req2, State}.