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

209 commits

Author SHA1 Message Date
James Fish
77d1082233 Fix memory issue with large return values in testcases
Previously http_SUITE:echo_body/1 and http_SUITE:check_raw_status/1
returned large values. Common test would then try to write these to the
logs causing tests to take a long time and use lots of memory.
2013-04-26 02:08:50 +01:00
Loïc Hoguin
ad91aaf81a Reorganize the http test suite 2013-04-24 20:28:44 +02:00
Loïc Hoguin
282e532ba9 Move SSL test certificates in a subdirectory 2013-04-22 19:27:47 +02:00
Loïc Hoguin
b58a0549e1 Add default operations for OPTIONS method in REST
It defaults to setting the Allow header to "HEAD, GET, OPTIONS".
2013-04-12 19:02:00 +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
Vladimir Dronnikov
180143f9b2 rest: reject incorrect content-type header 2013-04-12 14:58:08 +04:00
Loïc Hoguin
5a171d0f80 Remove process_post, post_is_create, create_path, created_path callbacks
Instead it will always go through content_types_accepted and it is
up to the resource code to do any creation and to return the created
path if the method is POST and the client should be redirected to the
created resource's location.

This removes the meta value 'put_path' as it is not needed anymore.

This fixes an issue with PATCH where content types were not normalized.
2013-04-11 22:25:36 +02:00
rambocoder
84d7671e91 Check the length before reading the body in body/1 and body_qs/1 2013-03-06 08:50:45 -05:00
Slava Yurin
bb1362c744 Add '*' matcher for parameters
For get_type_provided:
'*' will be match any parameters of media-range in "accept" header.
If '*' matched, then '*' is replaced by the matching parameters.
If Accept header is missing and '*' using, then in media_type in parameters
will be '*' and reply content-type will be without any parameters.

For content_types_accepted:
'*' will be match any parameters in "content-type" header.
2013-03-03 22:54:37 +07:00
Loïc Hoguin
3442acbe35 Run tests in parallel 2013-03-02 16:24:34 +01:00
Loïc Hoguin
0ba06578f2 Use random ports for tests 2013-03-02 14:39:05 +01:00
Loïc Hoguin
b2ffff9bec Add cowboy:set_env/3 2013-02-20 12:14:21 +01: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
d9b3727a62 Merge branch 'patch-1' of https://github.com/CamShaft/cowboy
Conflicts:
	src/cowboy_rest.erl
2013-01-29 22:33:03 +01:00
Tom Burdick
8a798014e9 allow POST rest handling to specify path after accepting content 2013-01-29 13:12:53 -06:00
Loïc Hoguin
a59c5d6e91 Merge branch 'rest_patch' of https://github.com/treetopllc/cowboy 2013-01-29 19:16:45 +01:00
Loïc Hoguin
85d05fff34 Fix chunked streaming of request body and improve speed 2013-01-29 19:12:34 +01:00
Tom Burdick
c4d1ee5547 add patch support to cowboy_rest 2013-01-29 11:34:20 -06:00
Loïc Hoguin
a357c49d1b New routing
Ultimately few things change, it's mostly just a nicer syntax and
slightly different expectations. The name of the value `dispatch`
did not change, because the previous dispatch values will now fail
if the code is not updated to using `cowboy_router:compile/1`.

No constraints have been implemented in this commit.
2013-01-28 16:53:09 +01:00
Loïc Hoguin
3b8a1365d1 Do not require inets for running tests anymore 2013-01-22 14:22:28 +01:00
Loïc Hoguin
81cfc1651e Improve keepalive tests 2013-01-21 14:34:33 +01:00
Loïc Hoguin
823a82b8f2 Fix an issue for replies in onresponse mishandling headers
Reported and fixed over email by Adrian Roe.
2013-01-20 19:06:28 +01:00
Loïc Hoguin
9bfef7c715 Update autobahntestsuite to 0.5.2
Also small mostly insignificant changes to tests.
2013-01-10 19:54:10 +01:00
Loïc Hoguin
01f57ad65d Add optional automatic response body compression
This behavior can be enabled with the `compress` protocol option.
See the `compress_response` example for more details.

All tests are now ran with and without compression for both HTTP
and HTTPS.
2013-01-07 22:42:16 +01:00
Loïc Hoguin
a013becc66 Add protection against slowloris vulnerability
This changes the behavior of the `timeout` protocol option to
mean "Time in which the full request line and headers must be
received". The default of 5s should be fine for all normal uses.

This change has no noticeable impact on performance and is thus
enabled by default for everyone. It can be disabled by setting
`timeout` to `infinity` although that is definitely not encouraged.

Inspired by the contribution from @naryl on github.
2013-01-06 19:49:01 +01:00
Loïc Hoguin
faeb37ed80 Add cowboy_req:set_resp_body_fun/2
This allows streaming a body without knowing the length in advance.
Also allows {stream, StreamFun} response body in the REST code.
2013-01-05 23:35:30 +01:00
Loïc Hoguin
54063de2ff Hello 2013 2013-01-04 15:10:03 +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
Loïc Hoguin
7ff2a62585 Make sure an incorrect port returns a 400 error 2012-12-22 16:45:04 +01:00
Loïc Hoguin
8bc6bde62f Remove the dependency on httpd_util
Add the function cowboy_clock:rfc1123/1 that formats the given
date to the RFC1123 format.
2012-12-03 15:57:27 +01:00
Loïc Hoguin
5c315ab142 Return a 400 error if the Accept header was incorrect 2012-11-30 16:44:57 +01:00
Loïc Hoguin
5f6b6b6f6d Add a better error message when user callbacks are not exported 2012-11-29 16:15:28 +01:00
Loïc Hoguin
aeb86e70c1 Add crypto into the required applications
As suggested by @prof3ta.
2012-10-11 20:13:23 +02:00
Loïc Hoguin
76cd1e40c9 The onresponse hook now receives 4 arguments, including the body
We do not always provide the body however. It is not available
when using chunked replies, or when using set_resp_body_fun.
2012-10-04 22:59:33 +02:00
Loïc Hoguin
2e0a2a1c9e Add max_headers option
It is only enforced when Cowboy needs to wait for more data.

Also fix a few types and a few status codes.
2012-09-29 13:57:30 +02:00
Loïc Hoguin
b2243aa544 Optimize cowboy_protocol
* #state{} changes are avoided where possible
* #state{} is now smaller and use less memory
* the Req object is created only after the whole request is parsed
* parsing makes use of a single binary match context
* external calls are avoided in the critical path
* URL fragment is now extracted properly (retrieval API next commit)
* argument orders to local functions modified to avoid extra operations
* dispatching waits as long as possible before tokenizing host/path
* handler opts are no longer shown in the error messages except in init

The code may not look as beautiful as it was before. But it really
is, for parsing code. The parsing section of the file may be skipped
if your eyes start to burn.
2012-09-26 14:20:29 +02:00
Loïc Hoguin
e27fd5fcb9 Make multipart part headers binary lowercase
Here we do not remove decode_packet yet, we just lowercase the
header name and transform it into a binary if needed, to fix
the consistency issue.
2012-09-21 13:07:51 +02:00
Loïc Hoguin
34021666cb Don't use decode_packet/3 for parsing the headers
Header names are now binaries. Since header names are case insensitive
they are all converted to lowercase. For example: <<"content-length">>.

The max_line_length option was removed. Three new options have been
added instead:

 *  max_request_line_length (defaults to 4096)
 *  max_header_name_length (defaults to 64)
 *  max_header_value_length (defaults to 4096)
2012-09-21 09:18:56 +02:00
Loïc Hoguin
8497c8bbcd Don't use decode_packet/3 for parsing the request-line
First step in making all methods and header names binaries to
get rid of many inconsistencies caused by decode_packet/3.

Methods are all binary now. Note that since they are case
sensitive, the usual methods become <<"GET">>, <<"POST">> and so on.
2012-09-21 08:54:57 +02:00
Loïc Hoguin
8d5f8db90a Improve consistency of return types for cowboy_req API
The signature of parse_header, body_qs, multipart_data and
the set_resp_* functions has changed.

See the cowboy_req module edoc for more details.
2012-09-17 13:56:58 +02:00
Loïc Hoguin
f39c001c03 Rename cowboy_http_static to cowboy_static 2012-08-27 13:53:27 +02:00
Loïc Hoguin
d3dcaf109b Rename cowboy_http_req to cowboy_req 2012-08-27 13:28:57 +02:00
Loïc Hoguin
9e2622becb Rename cowboy_http_protocol to cowboy_protocol 2012-08-27 12:58:04 +02:00
Loïc Hoguin
e4124de2c7 Switch to Ranch for connection handling
This is the first of many API incompatible changes.

You have been warned.
2012-08-27 11:50:35 +02:00
Loïc Hoguin
0c2e2224e3 Update version to 0.6.0
Also update the CHANGELOG and copyright years.
2012-05-23 14:53:48 +02:00
Loïc Hoguin
1a1b01c7c4 Remove a dumb warning when running the tests 2012-05-21 16:46:18 +02:00
Loïc Hoguin
295dc64eaa Merge branch 'serve-static-file' of https://github.com/klaar/cowboy
Fix alphabetical order since @klaar seems to have issues with it. ;)
2012-05-21 16:33:37 +02:00
Loïc Hoguin
cc6c4e39de Fix a bug preventing 'onresponse' from being called on errors 2012-05-21 15:17:24 +02:00
Loïc Hoguin
8363e8995a Small updates to the ROADMAP and doc comments 2012-05-21 08:49:22 +02:00
Loïc Hoguin
90bae59307 Add a test checking requests with size around the MTU 2012-05-05 07:53:17 +02:00