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

1465 commits

Author SHA1 Message Date
Loïc Hoguin
c55db9a8ff
Ensure Websocket errors result in a crash log 2017-02-18 20:21:02 +01:00
Loïc Hoguin
c4ed8e2a37
Erlang/OTP 19.2.3 2017-02-18 19:15:45 +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
80f8cda7ff
Remove or fix a small number of todo comments
One had the todo text fixed, another had the task to do done.
2017-02-05 20:45:36 +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
182f824138
Erlang/OTP 19.2.2 and 18.3.4.5 2017-02-05 15:10:26 +01:00
Loïc Hoguin
98c614ee0b
Add missing human-readable errors for HTTP/1.1 2017-02-05 15:10:00 +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
3c198f7d90
Fix and update the compress example to use cowboy_compress_h 2017-01-22 20:17:52 +01:00
Loïc Hoguin
413196ace1
Erlang/OTP 19.2.1 2017-01-22 15:52:46 +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
3b91523a3c
Fix error responses not including a content-length
This would prevent the client from knowing whether the request
was received fully without the connection closing first.
2017-01-20 16:06:27 +01:00
Loïc Hoguin
353dc29d8f
Fix protocol breaking when user tries to send empty chunk
The {data, IsFin, Data} uses IsFin to indicate whether this
is the last chunk, while chunked transfer-encoding uses the
length of Data, and ends when it is 0. We must therefore not
send chunks with empty data.
2017-01-20 15:16:50 +01:00
Loïc Hoguin
0f8452cafa
Add support for multiple stream handlers
The stream handlers can be specified using the protocol
option 'stream_handlers'. It defaults to [cowboy_stream_h].

The cowboy_stream_h module currently does not forward the
calls to further stream handlers. It feels like an edge
case; usually we'd want to put our own handlers between
the protocol code and the request process. I am therefore
going to focus on other things for now.

The various types and specifications for stream handlers
have been updated and the cowboy_stream module can now
be safely used as a behavior. The interface might change
a little more, though.

This commit does not include tests or documentation.
They will follow separately.
2017-01-16 14:36:33 +01:00
Loïc Hoguin
e5a8088e68
Make the new cowboy_req tests more realistic 2017-01-04 19:45:35 +01:00
Loïc Hoguin
f34ef2ceae
Improve the manual for the new resp_header functions 2017-01-04 19:21:23 +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
1048bff929
Update rebar.config 2017-01-03 12:15:42 +01:00
Loïc Hoguin
c5a9771ac4
Remove ROADMAP file
The only ROADMAP now is small fixes toward making it stable
and very little interface changes, so the file is not that
useful anymore.
2017-01-02 19:42:47 +01:00
Loïc Hoguin
43adacc760
Welcome to 2017 2017-01-02 19:36:36 +01:00
Loïc Hoguin
fac882164c
Update Erlang.mk 2017-01-02 19:28:48 +01:00
Loïc Hoguin
0e2bd04cc9
Update README 2017-01-02 19:28:11 +01:00
Loïc Hoguin
2dff25a61d
Remove AUTHORS file
Information can be found in cgit.
2017-01-02 19:27:50 +01:00
Loïc Hoguin
309780a9fd
Remaining Dialyzer fixes 2017-01-02 18:27:03 +01:00
Loïc Hoguin
637706ff1f
Update Ranch to 1.3.0 2017-01-02 16:47:54 +01:00
Loïc Hoguin
e10daf39fa
Numerous Dialyzer fixes 2017-01-02 16:47:16 +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
Loïc Hoguin
271e31c629
Various fixes and tweaks to the user guide 2017-01-02 14:46:19 +01:00
Loïc Hoguin
5838a0c81a
Add templates as Erlang.mk plugin 2016-12-28 17:54:50 +01:00
Loïc Hoguin
f7094ad78f
Update the cowboy_rest manual 2016-12-28 15:17:43 +01:00
Loïc Hoguin
afc7d08813
Leave a few manual pages for post 2.0.0-pre.4
In particular the cowboy_sub_protocol is subject to change soon.
Also the cowboy_stream behavior is going to be left hidden in
this release and enabled when it becomes easier to chain them.
2016-12-23 18:56:05 +01:00
Loïc Hoguin
3bcb1cb42e
Update cowboy_middleware 2016-12-23 18:52:02 +01:00
Loïc Hoguin
5da7d1ef05
Update cowboy_loop manual 2016-12-23 17:20:54 +01:00
Loïc Hoguin
b13c07932d
Update the cowboy_handler manual
Also fixes a small mistake in cowboy_websocket.
2016-12-23 15:33:21 +01:00
Loïc Hoguin
98ae01b599
Update the cowboy_static manual 2016-12-23 12:19:27 +01:00
Sasan Hezarkhani
56e489f00a
Updates cowboy_http documents changelog
The changelog had a wrong reference to an option that was updated.
`max_header_request_line_length` -> `max_request_line_length`
2016-12-22 23:56:48 +01:00
Loïc Hoguin
cbc7056395
Update cowboy_websocket_manual 2016-12-22 18:13:25 +01:00
Loïc Hoguin
e584412de7
Add the manual for cowboy_http2 2016-12-22 15:19:38 +01:00
Loïc Hoguin
a9d9c9d902
Add cowboy_http manual
Updates and replaces the cowboy_protocol manual.
2016-12-22 14:48:02 +01:00
Loïc Hoguin
a1b52494a5
Update the cowboy_router manual 2016-12-22 12:53:21 +01:00
Loïc Hoguin
89120a3606
Update CI release list 2016-12-21 17:20:27 +01:00
Loïc Hoguin
ba14cf7838
Add man pages for the reply functions 2016-12-21 15:47:44 +01:00
Loïc Hoguin
f57dd51e0f
Update Erlang.mk 2016-12-02 19:23:19 +01:00
Loïc Hoguin
c528d9b0f7
Add the man pages for body reading functions
[ci skip]
2016-12-02 16:50:55 +01:00