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

2184 commits

Author SHA1 Message Date
Loïc Hoguin
193968d53e Fix spec for cowboy_dispatcher:split_host/1. 2011-03-21 22:13:27 +01:00
Loïc Hoguin
7cacb88fec Introduce cowboy_http_req:body/1 to read the full request body. 2011-03-21 22:08:27 +01:00
Loïc Hoguin
e9781e77f1 Make sure error_response always returns ok. 2011-03-21 17:52:27 +01:00
Loïc Hoguin
e3dc9b2694 Add specs to ensure_response and change the clauses order. 2011-03-21 17:51:21 +01:00
Loïc Hoguin
8b02992e6a Skip the request body if it hasn't been read by the handler. 2011-03-21 17:47:17 +01:00
Loïc Hoguin
e40001a884 Ensure a response is sent when the handler doesn't reply anything. 2011-03-20 19:38:45 +01:00
Loïc Hoguin
a1e56a2fba Move the error response code into a separate function. 2011-03-20 19:29:32 +01:00
Loïc Hoguin
71b31cee92 Make sure we can only reply to an HTTP request inside Handler:handle.
Of course since requests are a record the response state can be explicitly
overriden, but standard use prevents errors by making sure only one reply
is sent.
2011-03-20 18:03:36 +01:00
Loïc Hoguin
d69d0adfa7 Lazy-retrieve the peer name and port to avoid wasting time each request. 2011-03-20 16:09:05 +01:00
Loïc Hoguin
f5e7178651 Change a @todo for Handler:init possible return values. 2011-03-20 15:30:29 +01:00
Loïc Hoguin
a3fff2f5b0 Rename a variable in cowboy_http_protocol for clarity. 2011-03-20 15:10:58 +01:00
Loïc Hoguin
df35916d2a Allow code reloading inside the cowboy_http_protocol module during keep-alive. 2011-03-20 14:24:43 +01:00
Loïc Hoguin
c4d4b6a051 Rename the title for Getting Started in the README. 2011-03-20 14:15:58 +01:00
Loïc Hoguin
6fad3f7824 Default the connection to keep-alive on HTTP/1.1 and close on 1.0. 2011-03-20 00:09:15 +01:00
Loïc Hoguin
896b854908 Remove a dead code clause for split_path. 2011-03-20 00:03:02 +01:00
Loïc Hoguin
b874b28561 Save the raw path string in the request. 2011-03-20 00:01:29 +01:00
Loïc Hoguin
8085529f48 Save the raw host string in the request. 2011-03-19 23:57:23 +01:00
Loïc Hoguin
bd3a646316 Protect the calls to the handler using catch.
* Handler:init shouldn't reply anything; send an error 500.
* Handler:handle may have sent something to the client; close the socket.
* Handler:terminate failed to clean itself up. Close the socket.
2011-03-19 19:51:44 +01:00
Loïc Hoguin
a4f8bb6573 Add support for the '*' path.
Mostly used by the following request: OPTIONS * HTTP/1.1
2011-03-19 18:53:59 +01:00
Loïc Hoguin
2c52a30b0a Rewrite the dispatcher to take a list of host each having a list of paths.
* Makes more sense to parse the host only once instead of for each path.
* Allows proper handling of: If the host is not a valid host on the server,
  the response MUST be a 400 (Bad Request) error.
2011-03-19 17:42:03 +01:00
Loïc Hoguin
ebe638165e Ignore all extra Host values sent in the request. 2011-03-19 16:49:06 +01:00
Loïc Hoguin
673c7e2cb5 Reply with error 501 on all non absolute path URIs for now. 2011-03-19 14:46:45 +01:00
Loïc Hoguin
7ef67d08fe Reply with error 400 on all bad Request-Lines received. 2011-03-19 14:40:39 +01:00
Loïc Hoguin
c9eb3ce5fc Ignore empty lines when expecting the Request-Line.
In the interest of robustness, servers SHOULD ignore any empty
line(s) received where a Request-Line is expected.  In other words,
if the server is reading the protocol stream at the beginning of a
message and receives a CRLF first, it should ignore the CRLF.
2011-03-19 14:38:31 +01:00
Loïc Hoguin
db715a3eb1 Comparisons of host names MUST be case-insensitive. 2011-03-19 14:16:17 +01:00
Loïc Hoguin
2131a935e6 Notify the client that we're closing the connection after the error reply. 2011-03-19 02:21:55 +01:00
Loïc Hoguin
408f167621 Move the reply function to cowboy_http_req. 2011-03-18 22:38:26 +01:00
Loïc Hoguin
c6ad0273a8 Introduce Handler:terminate to cleanup the handler's state. 2011-03-18 13:47:37 +01:00
Loïc Hoguin
5e80e4baac Handler:init/2 should also return the Request in case it changed. 2011-03-18 01:52:46 +01:00
Loïc Hoguin
f53235549d Introduce Handler:init/2 for initializing the handler state.
We need an init function in order to process upgrade instructions
for protocols like WebSockets, but also to request an active receive
mode for long-polling connections, both of which will be implemented
at a later time.
2011-03-18 00:15:46 +01:00
Loïc Hoguin
a77b906b9f Don't crash on Transport:controlling_process return in the acceptor.
Crashes can happen if we close the connection too fast, leading to
controlling_process returning {error, closed} instead of ok. This can
happen when we receive bad requests, reply with 404 Not Found and more.
Simply do not match the return value of controlling_process to avoid this.
2011-03-17 22:22:09 +01:00
Loïc Hoguin
0069e2465d Remove a superfluous terminate call in error_terminate. 2011-03-17 22:06:39 +01:00
Loïc Hoguin
786a05a129 Run the dispatcher as early as possible to quickly dismiss 404 errors. 2011-03-17 22:02:47 +01:00
Loïc Hoguin
da72255940 Initial commit. 2011-03-17 00:29:35 +01:00