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

139 commits

Author SHA1 Message Date
Loïc Hoguin
7f35f693fc Fix specs for cowboy_http_req:reply/4.
Body is iodata(), not iolist().
2011-04-14 14:13:26 +02:00
Loïc Hoguin
c32db277c8 Fix a bug where dupe headers were sent in cowboy_http_req:reply/4.
Now the server defines default headers that can be overwritten by the
handler simply by passing them to the reply/4 function. Default headers
include, for now, Connection and Content-Length headers. Note that it isn't
enough to change the Connection header to close a keep-alive connection
server-side.
2011-04-14 01:32:02 +02:00
Loïc Hoguin
4048499af2 Add a test case for cowboy_dispatcher:match/3.
Added it while debugging an issue, so why not keep it?
2011-04-14 01:10:57 +02:00
Loïc Hoguin
bc99200bae Add a Transport:messages/0 function to obtain the atoms sent in active mode.
That way we can support active mode without having to hardcode the atoms
for each transports available.
2011-04-12 16:27:44 +02:00
Loïc Hoguin
aab91c044b Don't enable binary optimization warnings by default.
It's problematic: both doing it right and doing it wrong trigger a warning
and we treat warnings as errors.
2011-04-12 16:23:52 +02:00
Loïc Hoguin
73b120b68e Fix a pattern matching bug in cowboy_http_protocol:handler_init/2. 2011-04-12 16:22:46 +02:00
Loïc Hoguin
0ef66b78f7 ct: Add a test for requests pipelining. 2011-04-10 02:43:30 +02:00
Loïc Hoguin
f05953516b ct: Add a test for \n which throws an error 400. 2011-04-09 15:45:25 +02:00
Loïc Hoguin
6ec20b736e Limit the number of empty lines to allow before the request-line.
Defaults to 5. Prevents someone from indefinitely sending empty lines.
2011-04-09 15:28:41 +02:00
Loïc Hoguin
c79df567be ct: Add tests for incomplete requests leading to a timeout. 2011-04-09 13:53:22 +02:00
Loïc Hoguin
21dc1cc546 ct: Add raw tests to check that errors are properly handled. 2011-04-09 12:59:53 +02:00
Loïc Hoguin
3a776b146e Initial work on a ct test suite for the HTTP protocol.
Handles two basic tests for both HTTP and HTTPS.
Also renames 'make test' into 'make tests'.
2011-04-08 16:30:37 +02:00
Loïc Hoguin
4cbba84a00 Discard the port from the host before tokenizing it. 2011-04-08 12:12:46 +02:00
Loïc Hoguin
0fad6c6fde Don't crash on errors while receiving headers; throw an error 500 instead.
The server shouldn't crash the request process when we have an error
while receiving headers. A case where this could happen is if the header
line is too long.

See also bfrog's report on ticket #3 on github.
2011-04-07 00:54:32 +02:00
Loïc Hoguin
d8a2fcf258 Don't automatically retrieve the peer information for the 'OPTIONS' method. 2011-04-05 20:09:49 +02:00
Loïc Hoguin
44e6f60b91 Handle properly the default Connection value for HTTP/1.0.
Fixes a bug reported by evaxsoftware on IRC.
2011-04-05 20:07:52 +02:00
Loïc Hoguin
04a5aa7c5c Add initial SSL transport support.
Code is working but hasn't been benchmarked yet.
2011-04-03 18:35:35 +02:00
Loïc Hoguin
17613e5305 Add a dialyze verb to the Makefile for convenience. 2011-04-03 16:07:27 +02:00
Loïc Hoguin
d51170b4bc Use rebar instead of ./rebar by default in the Makefile. 2011-04-03 16:00:22 +02:00
Loïc Hoguin
44f0eecdcf Fix a grammar error reported by DeadZen on IRC. 2011-04-03 15:45:55 +02:00
Loïc Hoguin
a8af32c54b Don't ignore the return values in cowboy:stop_listener/1. 2011-04-03 15:21:29 +02:00
Loïc Hoguin
cb079c8a34 Add an AUTHORS file. 2011-04-03 15:04:40 +02:00
Loïc Hoguin
ccf7a242b4 Ensure the listening socket gets closed with the listener supervisor.
Moved the Transport:listen call to cowboy_acceptors_sup. This make it
depend on a child of cowboy_listener_sup instead of cowboy_sup, which
isn't getting shut down when calling cowboy:stop_listener/1 and thus
didn't close the listening socket.
2011-04-03 01:44:52 +02:00
Loïc Hoguin
718baffa3c Make Cowboy an OTP application again, properly this time.
As requested by many people on IRC Cowboy is now a proper OTP application
to support soft code upgrades. It should also be easier to start and stop
listeners now using cowboy:start_listener/6 and cowboy:stop_listener/1.
2011-04-03 00:21:47 +02:00
Loïc Hoguin
e4da6956fc Anonymize and improve the cowboy supervision tree.
* Cowboy isn't an OTP application anymore; just a supervisor.
* All processes started by Cowboy are now anonymous.
* All processes related to a listener are now part of its supervision tree.
2011-04-02 20:27:16 +02:00
Loïc Hoguin
e6e5b1767f Merge remote-tracking branch 'nox/improve-http-req' 2011-03-29 14:48:40 +02:00
Anthony Ramine
101034842e Make the default value the last parameter of HTTP req accessors
This makes cowboy_http_req's qs_val/3, binding/3 and header/3 behave like
proplists:get_value/3.
2011-03-29 14:20:51 +02:00
Anthony Ramine
96a770620e Make HTTP req accessors call themselves with their default default value
Use lists:keyfind/3 in qs_val/3, binding/3 and header/3 and make qs_val/2,
binding/2 and header/2 call those.
2011-03-29 14:18:31 +02:00
Anthony Ramine
4eeabe5612 Fix cowboy_http_req:body with regard to the new accessors default value
header/2 now returns 'undefined' when the header isn't in the request.
2011-03-29 13:58:03 +02:00
Loïc Hoguin
150723ca21 Return undefined instead of failing or returning "" when a value doesn't exist. 2011-03-27 13:11:57 +02:00
Loïc Hoguin
d0d9b0e8b3 Use a more efficient variant of string:to_lower to improve performance.
After much testing and experimentation of all kinds I find lists to be both
faster and using less memory than binaries for request-line and headers
handling. This is more than likely due to the fact that headers are very
short and thus do not benefit from the advantages of refc binaries, meaning
they're copied, just like lists. The memory usage discrepancy is still a
mystery for the most part, although the hoops needed to perform operations
on the binaries are probably responsible for the extra memory use.

I'm thus giving up on trying to use binaries for request-line and headers.
Instead, this commit improves performances even more to the lists code,
making lists 5% faster than binaries. Lists are easier to work with too,
so I guess it's all a big win for everyone.

Of course the request body is still read as a binary, we're using the
binary type where it performs best.
2011-03-27 01:16:11 +01:00
Loïc Hoguin
5726aa3d85 Match early in connection_to_atom for a small performance improvement. 2011-03-27 01:11:33 +01:00
Loïc Hoguin
71e940a6eb Fix query string related type specs in cowboy_http_req. 2011-03-27 01:09:47 +01:00
Loïc Hoguin
c285f00349 Fix the type spec for qs_vals, a list of key/values. 2011-03-27 01:07:01 +01:00
Loïc Hoguin
e69597f29e Add the cowboy_http_handler behaviour. 2011-03-24 13:48:52 +01:00
Loïc Hoguin
e5bce3ca88 Merge remote-tracking branch 'ndim/master' 2011-03-23 13:56:17 +01:00
Hans Ulrich Niedermann
07413113d5 Makefile: Use a REBAR variable
Using a REBAR variable makes it easy for the user to override
the REBAR to be called.
2011-03-23 10:54:09 +01:00
Loïc Hoguin
9fe8141d2a Allow Handler:init/3 to request a protocol upgrade. 2011-03-22 23:03:43 +01:00
Loïc Hoguin
7888be00d2 Forward transport and protocol name to Handler:init. 2011-03-22 19:50:02 +01:00
Loïc Hoguin
e0185dd27f Add cowboy_tcp_transport:name/0 to ease transport identification later on. 2011-03-22 19:40:28 +01:00
Loïc Hoguin
3865415a60 Boring 80-col change. 2011-03-22 13:23:40 +01:00
Loïc Hoguin
06274cd8ab Introduce cowboy_http_req:body_qs/1 for automated urlencoded body parsing. 2011-03-22 13:20:21 +01:00
Loïc Hoguin
775a03e6eb Fix spec for cowboy_http_req:parse_qs/1. 2011-03-22 13:19:38 +01:00
Loïc Hoguin
c645b682e7 Fix spec for cowboy_http_req:body/1 and body/2. 2011-03-22 13:18:53 +01:00
Loïc Hoguin
c3a36246b5 Explicitly ignore the return value of cowboy_http_req:reply in error_response. 2011-03-22 12:27:34 +01:00
Loïc Hoguin
d4c071c2d0 Fix the type spec for path_tokens, a list of *non empty* strings. 2011-03-22 12:26:07 +01:00
Loïc Hoguin
06ff8607ed Add more dialyzer warnings to rebar.config. 2011-03-22 12:25:43 +01:00
Loïc Hoguin
3b6f3004a6 Add a rebar.config file with useful options. 2011-03-21 23:36:51 +01:00
Loïc Hoguin
1ebfa5eb1f Fix spec for cowboy_tcp_transport:close/1.
Apparently the documentation is wrong for gen_tcp:close/1, it returns only ok.
2011-03-21 22:57:07 +01:00
Loïc Hoguin
545116edfa Fix spec for cowboy_http_req:reply/4. 2011-03-21 22:47:37 +01:00