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

297 commits

Author SHA1 Message Date
Loïc Hoguin
7d9f6611ae
Fix the remaining http_SUITE test cases 2017-07-14 19:09:42 +02:00
Loïc Hoguin
23fcfe9eea
Fix more of the older tests
The Cowboy behavior has changed a little and gives more
accurate error responses now. And in some cases, successes.
2017-07-13 00:20:56 +02:00
Loïc Hoguin
ddb0c4f3b6
Fix a few of the older tests 2017-07-12 19:40:52 +02:00
Loïc Hoguin
cf4d8166f8
Remove tests for set_resp_body with a stream fun 2017-07-12 19:25:56 +02:00
Loïc Hoguin
3c18585945
Remove any mention of the waiting_stream hack 2017-07-12 18:55:09 +02:00
Loïc Hoguin
acc5fed589
Remove the onresponse tests from http_SUITE 2017-07-12 18:36:49 +02:00
Loïc Hoguin
3eb7693e4f
Remove outdated multipart tests
They have equivalents in req_SUITE.
2017-06-28 13:07:44 +02:00
Loïc Hoguin
ec00e3d60e
Make cowboy_req:read_part return multipart headers as map 2017-06-09 16:57:11 +02:00
Loïc Hoguin
6f7b59886e
Remove NumAcceptors argument from start_clear/tls
They are now cowboy:start_clear/3 and cowboy:start_tls/3.
The NumAcceptors argument can be specified via the
num_acceptor transport option. Ranch has been updated
to 1.4.0 to that effect.
2017-06-07 15:15:54 +02:00
Loïc Hoguin
767da623f1
Fix terminate not being called on connection close in HTTP/1.1
Introduces the new stream_handler_SUITE test suite. More cases
will be added later on.
2017-06-02 12:31:00 +02:00
Loïc Hoguin
5f421f93bc
Introduce the req_filter Websocket option
This option allows customizing the compacting of the Req object
when using Websocket. By default it will keep most public fields
excluding headers of course, since those can be large.
2017-05-28 20:19:39 +02:00
Loïc Hoguin
8cb125dbb7
Fix a harmless warning in tests 2017-05-23 14:10:05 +02:00
Loïc Hoguin
9ef4536656
Add many tests for RFC7540 5.1 and 5.1.1 and related fixes 2017-05-23 14:09:38 +02:00
Loïc Hoguin
4048f16365
Add a test suite for h2spec
h2spec must be preinstalled on the machine and its location
pointed at by the H2SPEC environment variable.
2017-05-23 14:05:00 +02:00
Loïc Hoguin
f3e5f3e410
Preliminary h2 flow control support
Existing tests pass. A number of things remain to be done.
Has only been tested with Gun so far. Feedback welcome!
2017-05-19 20:18:00 +02:00
Loïc Hoguin
78af194e07
Add a test for cowboy:set_env 2017-05-07 18:39:43 +02:00
Gary Rennie
4d92487f84
Add test for inactivity_timeout option in cowboy_http2
The inactivity timeout is used to close the connection in the absence of
any data from the client.

Since this is not part or the rfc7540 spec, a new http2_SUITE module has
been created with a test for the inactivity_timeout.
2017-05-05 18:46:12 +02:00
Loïc Hoguin
95d2855f62
Add the idle_timeout HTTP/1.1 protocol option
This fixes the connection being dropped because of request_timeout
despite there being some active streams.
2017-05-03 17:44:00 +02:00
Loïc Hoguin
0d81dc04f1
Add more HTTP/2 tests for RFC7540 4.1 and 4.3 2017-03-02 19:35:24 +01:00
Loïc Hoguin
bb83a6ce33
Unknown HTTP/2 frames are ignored 2017-02-26 13:24:15 +01:00
Loïc Hoguin
a3636adcac
Add many test cases covering RFC7540 4.2
These tests cover frame sizes. It's mostly edge cases for sure
(ie misbehaving clients and us having to reject them properly).
I had these almost ready for a long time, so I'm glad I can
push them out.

This requires updating Cowlib too (we currently track master).
2017-02-25 20:05:31 +01:00
Loïc Hoguin
9255cdf1d7
Change the type of bindings from a list to a map
Maps make more sense because the keys are unique.
2017-02-19 16:51:16 +01:00
Loïc Hoguin
91ae70b06c
Change the order of set_resp_cookie arguments
The Opts value is put last, to be more consistent with the
rest of the cowboy_req module.

Additionally a test handler was fixed which reduced the number
of errors in http_SUITE.
2017-02-19 09:46:11 +01:00
Loïc Hoguin
a45813c60f
Allow passing options to sub protocols
Before this commit we had an issue where configuring a
Websocket connection was simply not possible without
doing magic, adding callbacks or extra return values.
The init/2 function only allowed setting hibernate
and timeout options.

After this commit, when switching to a different
type of handler you can either return

  {module, Req, State}

or

  {module, Req, State, Opts}

where Opts is any value (as far as the sub protocol
interface is concerned) and is ultimately checked
by the custom handlers.

A large protocol like Websocket would accept only
a map there, with many different options, while a
small interface like loop handlers would allow
passing hibernate and nothing else.

For Websocket, hibernate must be set from the
websocket_init/1 callback, because init/2 executes
in a separate process.

Sub protocols now have two callbacks: one with the
Opts value, one without.

The loop handler code was largely reworked and
simplified. It does not need to manage a timeout
or read from the socket anymore, it's the job of
the protocol code. A lot of unnecessary stuff was
therefore removed.

Websocket compression must now be enabled from
the handler options instead of per listener. This
means that a project can have two separate Websocket
handlers with different options. Compression is
still disabled by default, and the idle_timeout
value was changed from inifnity to 60000 (60 seconds),
as that's safer and is also a good value for mobile
devices.
2017-02-18 18:26:20 +01:00
Loïc Hoguin
1504c60c89
Add test for the compress_response example 2017-02-05 17:32:03 +01:00
Loïc Hoguin
61d66a4de2
Remove outdated todo comments from req_SUITE 2017-02-05 17:12:29 +01:00
Loïc Hoguin
4cbdfdd293
Fix sending of large files with HTTP/2
Also finish implementing the relevant test, getting rid of todos.
2017-02-05 13:45:35 +01:00
Loïc Hoguin
f4fddbd0a1
Test Websocket protocol version 7
A bit late but at least removes a todo.
2017-02-05 11:27:54 +01:00
Jean-Sébastien Pédron
d8d7838a77
examples_SUITE: Query system to find GNU Make executable
... instead of hard-coding "make".

First, we check the value of `$MAKE`. If it's unset, we look for `gmake`
in the `$PATH`. If it's missing, we assume it's `make`.

This fixes the testsuite where GNU Make is installed as `gmake`.
2017-01-24 11:40:52 +01:00
Jean-Sébastien Pédron
2166733628
cowboy_static: Add support for files in EZ archives
If cowboy_static is initialized with `{priv_file, ...}` or `{priv_dir,
...}`, it is now able to read files from Erlang application .ez
archives.

When serving a file from an archive, the #file_info{} comes from the
archive, not the contained file, except for the size and type. The
erl_prim_loader module is used to read the latter's #file_info{} and the
actual file content (ie. sendfile(2) is not used in this case).
2017-01-24 11:36:58 +01:00
Loïc Hoguin
3e05ab8f82
Add experimental cowboy_compress_h stream handler
Currently marked as experimental because it can't be tweaked
(just enabled/disabled) and because it is not documented yet.
2017-01-22 10:50:39 +01:00
Loïc Hoguin
e5a8088e68
Make the new cowboy_req tests more realistic 2017-01-04 19:45:35 +01:00
Johan Lövdahl
3f4e79d42f
Add functions for getting and setting response headers 2017-01-04 13:37:50 +01:00
Loïc Hoguin
42c95b1584
Rewrite the tests for header name/value limits
Putting them in the correct test suite, with the proper
documentation etc.
2017-01-03 18:07:39 +01:00
José Valim
f59c29dff0
Return status 431 if the request header field is too large
This commit changes Cowboy to follow RFC6585.
2017-01-03 17:47:23 +01:00
Loïc Hoguin
43adacc760
Welcome to 2017 2017-01-02 19:36:36 +01:00
Loïc Hoguin
ed664345d7
Add a few more test cases for cowboy_req:match_qs 2017-01-02 14:56:20 +01:00
Christopher Adams
59c32506c0
Fix if_modified_since match of last_modified
Correct expected return type from `no_call` to `undefined` in
if_modified_since when last_modified callback is not defined. Add an
http_SUITE test to catch regressions.
2016-10-18 10:43:47 +02:00
Loïc Hoguin
1d01d0fc06 Allow websocket_init/1 to reply/close/hibernate 2016-08-15 19:21:38 +02:00
Loïc Hoguin
af88442610 Modernize the Websocket test suite 2016-08-15 18:06:16 +02:00
Loïc Hoguin
d1b65a67cf Remove Req from the Websocket interface
After the switch to Websocket, we are no longer in a request/response
scenario, therefore a lot of the cowboy_req functions do not apply
anymore.

Any data required from the request will need to be taken from Req
in init/2 and saved in the handler's state.
2016-08-12 19:27:23 +02:00
Loïc Hoguin
e44ac98c83 Merge branch 'master' of https://github.com/camshaft/cowboy 2016-08-12 17:26:28 +02:00
Loïc Hoguin
97986df276 Fix Websocket compression
The option for enabling Websocket compression has been
renamed. Previously it was shared with HTTP compression,
now it's specific to Websocket. The new option is named
'websocket_compress'.
2016-08-12 16:56:08 +02:00
Loïc Hoguin
b75b0a6d4d Use integer_to_binary when possible 2016-08-11 11:53:05 +02:00
Loïc Hoguin
699164fbdd Add a test for echo_get example undefined 2016-08-11 11:48:09 +02:00
Loïc Hoguin
e2d5c268aa Fix timer-sent events in the websocket example 2016-08-11 11:06:03 +02:00
Loïc Hoguin
83aa3f1b9c Use binary_to_integer instead of to list and back 2016-08-10 17:50:28 +02:00
Loïc Hoguin
e30d120bd8 Make reply functions return Req 2016-08-10 17:15:02 +02:00
Loïc Hoguin
aa6f2ab5a4 Update the multipart reading interface
Now named read_part/read_part_body, with a verb indicating action.
2016-08-10 15:09:04 +02:00
Loïc Hoguin
3a057683af Add a lot of todos 2016-08-10 11:52:41 +02:00