0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 04:30:25 +00:00
cowboy/test
Loïc Hoguin 5e006be01f Add support for loops in standard HTTP handlers
Now init/3 can return one of the following values to enable loops:
 - {loop, Req, State}
 - {loop, Req, State, hibernate}
 - {loop, Req, State, Timeout}
 - {loop, Req, State, Timeout, hibernate}

Returning one of these tuples will activate looping in the HTTP handler.
When looping, handle/2 is never called. Instead, Cowboy will listen
for Erlang messages and forward them to the info/3 function of the
handler. If a timeout is defined, Cowboy will also close the connection
when no message has been received for Timeout milliseconds.

The info/3 function is defined as info(Msg, Req, State). It can return
either of the following tuples:
 - {ok, Req, State}
 - {loop, Req, State}
 - {loop, Req, State, hibernate}

The first one ends the connection, calling terminate/2 before closing.
The others continue the loop.

Loops are useful when writing long-polling handlers that need to wait
and don't expect to receive anything. Therefore it is recommended to
set a timeout to close the connection if nothing arrives after a while
and to enable hibernate everywhere.

Normal HTTP handlers shouldn't need to use this and as such info/3
was made optional.
2011-10-10 17:27:52 +02:00
..
http_SUITE_data Initial work on a ct test suite for the HTTP protocol. 2011-04-08 16:30:37 +02:00
chunked_handler.erl Add chunked reply support. 2011-05-08 17:26:21 +02:00
dispatcher_prop.erl Add a PropEr test for cowboy_dispatcher:split_host/1 2011-07-26 10:46:06 +02:00
http_handler.erl Fix a bug where dupe headers were sent in cowboy_http_req:reply/4. 2011-04-14 01:32:02 +02:00
http_handler_init_shutdown.erl Allow HTTP handlers to skip the handle/2 step in init/3 2011-10-06 15:54:37 +02:00
http_handler_long_polling.erl Add support for loops in standard HTTP handlers 2011-10-10 17:27:52 +02:00
http_SUITE.erl Add support for loops in standard HTTP handlers 2011-10-10 17:27:52 +02:00
proper_SUITE.erl Add a PropEr test for cowboy_dispatcher:split_host/1 2011-07-26 10:46:06 +02:00
websocket_handler.erl Fix a crash in websocket_handshake when cowboy_http_req:compact/1 is used 2011-10-06 01:07:49 +02:00
websocket_handler_init_shutdown.erl Add {shutdown, Req} to websocket_init/3 to fail a websocket upgrade 2011-10-10 09:09:15 +02:00
ws_timeout_hibernate_handler.erl Add a test for websocket hibernate + timeout and fix this use case 2011-09-22 23:15:54 +02:00