0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 20:50:24 +00:00
Commit graph

16 commits

Author SHA1 Message Date
Loïc Hoguin
8cc353114e Update specs that were too wide 2014-06-30 17:36:43 +02:00
Loïc Hoguin
17af50812c Remove outdated comments, all edoc, plus a few minor tweaks 2014-03-26 19:05:59 +01:00
Loïc Hoguin
903594bb87 Update copyright years 2014-02-06 19:57:23 +01:00
James Fish
1c474af8ee Fix loop handler keepalive race condition
Previously if a loop handler received the timeout message from a
previous request on the same connection the socket would be set to
{active, once} incorrectly - when a socket packet was already in the
message queue. This second packet would not be added to the buffer
before a Handler:info/3 call if a user message was in the message
queue before both socket packets.
2013-11-18 23:19:37 +00:00
Loïc Hoguin
bbee34fe16 Crash on failure, don't report errors
When something went wrong in a handler we used to report errors
and then terminate the process normally. This doesn't work so
well with links which won't detect failure.

Now we still catch the error, but throw another one with more
details on why it happened, including the Req object information
and the stacktrace. Ranch will then print an error message with
all this information.

Because we crash directly, this also means that we will not hog
resources unnecessarily for too long when something bad happens.
2013-08-24 20:36:23 +02:00
Loïc Hoguin
df73a4d0a5 Move cowboy_http:status() to cowboy:http_status() 2013-05-16 16:29:24 +02:00
Loïc Hoguin
61ca459feb Don't receive data from the socket only once in the loop handler 2013-04-12 14:34:36 +02:00
Loïc Hoguin
2aabc73045 Ensure we can fetch the body in the info/3 function of loop handlers 2013-04-12 14:32:37 +02:00
James Fish
b61f535134 Fix to prevent loop handler awakening immediately after response sent
If a loop handler sent a response (e.g. cowboy_req:chunked_reply/2,/3)
and then returns {loop, Req, HandlerState, hibernate} it
would have a {cowboy_req, resp_sent} message in its message queue. This
message would cause the process to immediately awaken, so it is flushed
before hibernation.
2013-02-22 18:36:13 +00:00
Egobrain
73c718dcb5 Added warn compile options. Fixed compile warnings. 2013-02-21 18:32:23 +04:00
James Fish
c42e672dd0 Fix {suspend, ...} specs to use atom() for function name 2013-02-17 02:11:45 +00:00
Andrew Majorov
3ea855137c Make sure socket is passive once we've done with loop handler
It is sometimes important to make a socket passive as it was initially
and as it is expected to be by cowboy_protocol, right after we've done
with loop handling.
2013-02-15 15:34:01 +04:00
Loïc Hoguin
40b8d0befc Better handle socket closing with loop handlers
We now read from the socket to be able to detect errors or TCP close
events, and buffer the data if any. Once the data receive goes over
a certain limit, which defaults to 5000 bytes, we simply close the
connection with an {error, overflow} reason.
2013-02-11 09:03:13 +01:00
Loïc Hoguin
638638a841 Fix {cowboy_req, resp_sent} potentially leaking in loop handlers 2013-01-29 14:35:26 +01:00
Loïc Hoguin
647e95aed1 Replace terminate/2 with terminate/3, adding a Reason
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.
2013-01-22 02:34:18 +01:00
Loïc Hoguin
1b3f510b7e Add middleware support
Middlewares allow customizing the request processing.

All existing Cowboy project are incompatible with this commit.
You need to change `{dispatch, Dispatch}` in the protocol options
to `{env, [{dispatch, Dispatch}]}` to fix your code.
2013-01-03 22:47:51 +01:00