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

174 commits

Author SHA1 Message Date
Loïc Hoguin
56369d5c1a Introduce cowboy_listener for managing a listener
Currently only supports limiting the maximum number of
connections by managing connection pools.
2011-08-10 16:43:59 +02:00
Loïc Hoguin
6138901465 Fix cookie tests and specs 2011-07-26 17:39:41 +02:00
Loïc Hoguin
528d0ebffd Small cosmetic changes and doc update to the cookie patch 2011-07-26 13:58:48 +02:00
Tom Burdick
b75859e075 Fail early in cookie-related API functions 2011-07-26 13:53:52 +02:00
Tom Burdick
5bd936db66 Implement cookies in cowboy_http_req 2011-07-26 13:53:31 +02:00
Tom Burdick
a29ccb070b Add cowboy_cookies for cookie creation and parsing
Based on Mochi Media, Inc.'s work in Mochiweb.

Conflicts:

	rebar.config
2011-07-26 13:52:21 +02:00
Loïc Hoguin
acc5f50ab5 Update quoted to 1.0.3 to fix outstanding issues
Magnus Klaar updated the PropEr tests and it should be fine now.
2011-07-26 12:36:35 +02:00
Loïc Hoguin
e5d4c1f22f Add a PropEr test for cowboy_dispatcher:split_host/1
Mostly thanks to Magnus Klaar as it took me a while to figure
out how PropEr tests had to be written.
2011-07-26 10:46:06 +02:00
Loïc Hoguin
503a0c7662 URL decode paths
This fixes issue #33.
2011-07-20 22:07:35 +02:00
Loïc Hoguin
fa20273b37 URL decode query strings
Should be good for both GET and POST query strings.

This adds https://github.com/klaar/quoted.erl as a dependency.
Props to klaar for this code.
2011-07-20 17:38:10 +02:00
Loïc Hoguin
293cf33702 Separate message and packet handling for websockets
Improves the readability of websocket handler code by having
two functions: websocket_handle/3 handles the packets received
from the socket, removing the tuple construct that was otherwise
needed, so only websocket_handle(Data, Req, State) is needed now;
websocket_info/3 handles the messages that the websocket handler
process received, as websocket_info(Info, Req, State).

Both functions return values are handled identically by Cowboy
so nothing changes on that end.
2011-07-19 12:20:16 +02:00
Loïc Hoguin
d363f91410 Fail fast when a wrong type is given to API functions
Idea given by bfrog, fixes issue #34.
2011-07-18 14:21:45 +02:00
Loïc Hoguin
87366e36ad Call websocket_close/4 *after* throwing the error
This ensures that an error thrown in handler_terminate/4 will be
shown after the error from handler_call/6, in the expected order.

As we already call WebSocketHandler:terminate/3, this should
fix issue #23.
2011-07-07 17:50:46 +02:00
Loïc Hoguin
474f4e0bfa Call Handler:terminate/2 even on error in Handler:handle/2
This ensures we can cleanup what we did in Handler:init/3.
2011-07-07 17:45:28 +02:00
Loïc Hoguin
aa0a66749e Move recursion out of a try .. catch block.
Fixes issue #31.

Recursion shouldn't happen in a single catch statement or inside
a try .. catch statement. The only safe construct for catching
exceptions and perform recursion when everything goes well is
to put the recursive call inside a try .. of .. catch construct
in the of .. catch block.

Otherwise the stack gets filled with exception-related information
since they can still be caught if we were to send them and unfold
the whole thing.

Thanks go to lpgauth for reporting the issue and people on IRC
for explaining the hows and whys.
2011-07-06 20:00:08 +02:00
Loïc Hoguin
108a491f55 Add documentation for the public interface.
This is probably not perfect yet but it should be better than
nothing. We'll improve things with feedback received from the
many users.
2011-07-06 17:42:20 +02:00
Loïc Hoguin
2b3bfdd783 Add a link to cowboy_examples in the README 2011-06-30 14:04:06 +02:00
Loïc Hoguin
6b1fb5f390 Fix the @equiv EDoc tags 2011-06-30 01:11:11 +02:00
Loïc Hoguin
58267689f0 Add the remaining missing specs
Found thanks to warn_missing_spec and added with the help of typer.
Eunit functions do not have specs yet however.
2011-06-27 23:36:17 +02:00
Loïc Hoguin
227529761c Merge pull request #29 from smarkets/ws-default-ports
do not send ports 80 and 443 - browsers get mad
2011-06-27 07:06:34 -07:00
Steven Gravell
bebe3dc5d2 do not send ports 80 and 443 - browsers get mad
Browsers get mad that the returned location address is not the same
as what they sent, since the :(80|443) is stripped.

Add a simple eunit test due to existing ct websockets tests not
covering this case.
2011-06-27 15:25:30 +01:00
Loïc Hoguin
f03dbf4d06 Use dialyzer directly instead of through rebar
Rebar recently removed their dialyzer support options so we're switching
to plain dialyzer. And as a bonus it works much better!
2011-06-21 17:24:07 +02:00
Loïc Hoguin
c427c7f8ec Merge remote-tracking branch 'skarab/listen-ip' 2011-06-21 17:17:09 +02:00
Hunter Morris
5f438561e9 Pass {ip, Ip} configuration through for TCP and SSL transports 2011-06-21 16:02:33 +01:00
Loïc Hoguin
a93eb02646 Fix a binary warning in cowboy_clock.
Just a change in the order of arguments of update_rfc1123.
2011-06-07 17:26:53 +02:00
Loïc Hoguin
648921b8cf Add hibernate support for websockets.
Return {ok, Req, State, hibernate}
or {reply, Data, Req, State, hibernate} to hibernate the websocket
process and save up memory and CPU. You should hibernate processes
that will receive few messages. So probably most of them.
2011-06-06 18:15:36 +02:00
Loïc Hoguin
b00dd6fba2 Add a 'profile' environment variable to start a profiler when the app starts. 2011-06-06 14:26:47 +02:00
Loïc Hoguin
2fa1e53928 Compile the binary match pattern for websockets only once. 2011-06-06 13:48:41 +02:00
Loïc Hoguin
919fa638ee Add function cowboy_http_req:compact/1 to regain memory.
It removes all the non-essential data from the HTTP request record.
It allows some applications to make better use of their memory,
for example websockets which do not need to keep all the headers
information and can simply discard it using this function.
2011-06-01 12:49:03 +02:00
Loïc Hoguin
3cfdf46e97 Remove a binary warning from websocket_data by removing a byte_size call. 2011-05-31 12:48:59 +02:00
Loïc Hoguin
ad2e905a81 Send a meaningful error to error_logger on websocket handler crashes.
Same as commit 4c4030a792 but for websockets.
See also issue #13 on github.
2011-05-27 12:32:02 +02:00
Loïc Hoguin
3e55cb62c9 Refresh the type specifications.
Following discussions on #erlounge.

Also fixes compilation in R14B03 and fixes a few underspecs
dialyzer warnings.
2011-05-25 23:02:40 +02:00
Loïc Hoguin
0720d6b9e3 Automatically start crypto, public_key and ssl if needed.
Following mochiweb and misultin's example here even though I'm not
too thrilled about starting them and not stopping but it's optional
and the application's author can start/stop them as normal anyway.
2011-05-24 20:52:19 +02:00
Loïc Hoguin
4c4030a792 Send a meaningful error to error_logger on handler crashes.
Inspired by gen_server and friends. Should fix issue #13.
2011-05-20 01:28:55 +02:00
Loïc Hoguin
548a9a15b8 README: Grammar fixes.
Thanks Mewn!
2011-05-16 12:36:52 +02:00
Loïc Hoguin
42111aa11f Merge remote-tracking branch 'nox/code-coverage' 2011-05-16 12:27:53 +02:00
Loïc Hoguin
4e4df58242 Makefile: Clean build the application before starting tests. 2011-05-16 12:16:26 +02:00
Loïc Hoguin
98b9b1124c Merge remote-tracking branch 'nox/path-info' 2011-05-16 12:08:55 +02:00
Anthony Ramine
107eba92a3 Enable code coverage 2011-05-16 11:42:15 +02:00
Anthony Ramine
4e09d776f5 Document the path info feature 2011-05-16 11:39:03 +02:00
Loïc Hoguin
9f06bac7bf Only try to update the Date field once every seconds. 2011-05-14 18:50:43 +02:00
Loïc Hoguin
c7069e7fb9 Add the Server header in the HTTP replies. 2011-05-14 18:46:50 +02:00
Loïc Hoguin
95006c3291 Add the required Date header in the HTTP replies.
The formatted date is generated and kept up to date regularly
by a gen_server process storing it in the cowboy_clock ets table.
Then it is retrieved by other processes simply by reading the table.
2011-05-14 15:20:12 +02:00
Loïc Hoguin
5d698250b2 Add a max_connections transport option.
Limits the number of parallel requests processed at once.
Waiting requests are kept in the accept queue.
The limit is not explicitly observed, but it should be
around the given value at any time. Defaults to 1024.

Thanks to ostinelli's benchmark to point out the issue hopefully
solved by this and the previous commit.
2011-05-09 22:01:31 +02:00
Loïc Hoguin
b3d3045cae Increase the default backlog from 128 to 1024.
Improves reliability under heavy load.
2011-05-09 20:37:12 +02:00
Anthony Ramine
0ca8f1364b Implement path_info feature
The dispatcher now accepts '...' as the leading segment of Host and the
trailing segment of Path, this special atom matches any remaining path tail.

When given "cowboy.bugs.dev-extend.eu", host rule ['...', <<"dev-extend">>,
<<"eu">>] matches and fills host_info with [<<"cowboy">>, <<"bugs">>].

When given "/a/b/c/d", path rule [<<"a">>, <<"b">>, '...'] matches and fills
path_info with [<<"c">>, <<"d">>].
2011-05-09 15:14:38 +02:00
Anthony Ramine
094f5c1735 Remove a superfluous function clause in try_match 2011-05-09 13:06:47 +02:00
Loïc Hoguin
420f5baf98 Add chunked reply support.
Send the status line and headers using
cowboy_http_req:chunked_reply/3, and
individual chunks with cowboy_http_req:chunk/2.
2011-05-08 17:26:21 +02:00
Loïc Hoguin
18582a7a39 Separate building the response head from replying. 2011-05-08 14:40:58 +02:00
Loïc Hoguin
39513deaca Removed a few lines from the README for pedantic correctness. 2011-05-07 16:22:19 +02:00