mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Fix chunked_hello_world example
This commit is contained in:
parent
b82bb92f7e
commit
6f75598b70
4 changed files with 96 additions and 9 deletions
|
@ -16,9 +16,9 @@ start(_Type, _Args) ->
|
|||
{"/", toppage_handler, []}
|
||||
]}
|
||||
]),
|
||||
{ok, _} = cowboy:start_http(http, 100, [{port, 8080}], [
|
||||
{env, [{dispatch, Dispatch}]}
|
||||
]),
|
||||
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{
|
||||
env => #{dispatch => Dispatch}
|
||||
}),
|
||||
chunked_hello_world_sup:start_link().
|
||||
|
||||
stop(_State) ->
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
-export([init/2]).
|
||||
|
||||
init(Req, Opts) ->
|
||||
Req2 = cowboy_req:chunked_reply(200, Req),
|
||||
cowboy_req:chunk("Hello\r\n", Req2),
|
||||
cowboy_req:chunked_reply(200, Req),
|
||||
cowboy_req:chunk("Hello\r\n", Req),
|
||||
timer:sleep(1000),
|
||||
cowboy_req:chunk("World\r\n", Req2),
|
||||
cowboy_req:chunk("World\r\n", Req),
|
||||
timer:sleep(1000),
|
||||
cowboy_req:chunk("Chunked!\r\n", Req2),
|
||||
{ok, Req2, Opts}.
|
||||
cowboy_req:chunk("Chunked!\r\n", Req),
|
||||
{ok, Req, Opts}.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue