aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_handler_long_polling.erl
AgeCommit message (Collapse)Author
2013-01-22Replace terminate/2 with terminate/3, adding a ReasonLoïc Hoguin
This should have been done a *long* time ago, back when I initially added Websocket support. This is the first part of two in improving loop handler support with regards to socket closure. Reason may include: {normal, shutdown} for the most normal shutdown, {normal, timeout} for a loop handler timeout shutdown, or {error, _} if an error occured.
2012-08-27Rename cowboy_http_req to cowboy_reqLoïc Hoguin
2012-04-29Fix and rework the HTTP test suiteLoïc Hoguin
Use a proper HTTP client to run all tests. This client is currently undocumented and should not be used. Includes a few fixes: * Fix a bug in the max_keepalive test * Fix a bug with max_keepalive handling * Fix a bug in stream_body/1 where data was lost under some conditions The tests now run quite faster than before. All the tests now run twice: once for TCP, once for SSL.
2011-10-13Add shortcuts to reply functionsLoïc Hoguin
New functions are reply/2, reply/3, chunked_reply/2 in cowboy_http_req.
2011-10-10Add support for loops in standard HTTP handlersLoïc Hoguin
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.