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

622 commits

Author SHA1 Message Date
Loïc Hoguin
8d920f3db9
Add the {deflate, boolean()} Websocket command
It allows to temporarily disable Websocket compression
when it was negotiated. It's ignored otherwise. This
can be used as fine-grained control when some frames
do not compress well.
2018-11-13 15:55:09 +01:00
Loïc Hoguin
8164b50453
Add deflate options for Websocket compression
They allow the server to configure what it is willing to accept
for both the negotiated configuration (takeover and window bits)
and the other zlib options (level, mem_level and strategy).

This can be used to reduce the memory and/or CPU footprint of
the compressed data, which comes with a cost in compression ratio.
2018-11-12 18:12:44 +01:00
Loïc Hoguin
fe1ee080de
Enable range requests support in cowboy_static 2018-11-11 16:25:45 +01:00
Loïc Hoguin
7840f6db7b
Add ProvideRangeCallback tests using sendfile
And fix this case when multiple ranges are requested.
2018-11-11 16:09:28 +01:00
Loïc Hoguin
dd0fbab6b7
Add automatic ranged request handling for bytes units
Returning the atom auto instead of a callback informs Cowboy
that it needs to handle range requests automatically. This
changes the behavior so that the ProvideCallback function
is called and then Cowboy splits the data on its own and
sends the response without any other user involvement other
than defining the ranges_provided/2 callback.

This is a quick and dirty way to add range request support
to resources, and will be good enough for many cases including
for cowboy_static as it also works when the normal response
body is a sendfile tuple.
2018-11-11 13:57:26 +01:00
Loïc Hoguin
d7b7580b39
Add sendfile support to cowboy_req:stream_body
It is now possible to stream one or more sendfile tuples.
A simple example of what can now be done would be for
example to build a tar file on the fly using the sendfile
syscall for sending the files, or to support Range requests
with more than one range with the sendfile syscall.

When using cowboy_compress_h unfortunately we have to read
the file in order to send it. More options will be added
at a later time to make sure users don't read too much
into memory. This is a new feature however so existing
code is not affected.

Also rework cowboy_http's data sending to be flatter.
2018-11-09 17:42:37 +01:00
Loïc Hoguin
29043aa7b4
Add support for range requests (RFC7233) in cowboy_rest
This is currently undocumented but is planned to be documented
in the next version.
2018-11-07 18:55:06 +01:00
Loïc Hoguin
805a156785
Test stop against all relevant REST callbacks 2018-11-05 10:30:26 +01:00
Loïc Hoguin
06f9f3714f
Test switch_handler against all relevant REST callbacks 2018-11-05 10:01:51 +01:00
Loïc Hoguin
8c9ad7bf07
Add the rate_limited/2 REST callback 2018-11-04 11:58:59 +01:00
Loïc Hoguin
bf7ccc8623
Add a test suite for RFC6585 2018-11-03 20:57:51 +01:00
Loïc Hoguin
be09711687
Add an option to disable sendfile for a listener 2018-11-03 18:55:40 +01:00
Loïc Hoguin
571719a164
Add a charset option to cowboy_static 2018-11-02 15:36:41 +01:00
Loïc Hoguin
e0b036fe68
Add tests for charsets_provided
Fix cases where the q-value is 0 and where a wildcard
was sent in the accept-charset header.

Also don't send a charset in the content-type of the
response if the media type is not text.

Thanks to Philip Witty for help figuring this out.
2018-11-02 13:54:19 +01:00
Loïc Hoguin
399b6a16b4
Better handle content negotiation when accept contains charsets
Thanks to Philip Witty for help figuring this out.
2018-11-02 13:49:54 +01:00
Loïc Hoguin
b3bfcf068c
Add a cowboy_rest test for malformed if-*-match headers 2018-10-31 22:41:59 +01:00
Steve Domin
09bf1199aa
Add compress_threshold protocol option
Currently the compression threshold is set to 300 and hardcoded in the
codebase. There are cases where it make sense to allow this to be
configured, for instance when you want to enforce all responses to be
compressed regarldess of their size.
2018-10-31 17:05:11 +01:00
Grigory Starinkin
5ab5615ff0
Handle error_response command in cowboy_metrics_h 2018-10-31 15:13:23 +01:00
Loïc Hoguin
473e3fb82b
Improve a few types, including cowboy_req:req() 2018-10-31 14:11:45 +01:00
Loïc Hoguin
a8335c63df
Always dialyze tests and fix some cowboy_req specs 2018-10-31 10:50:57 +01:00
Loïc Hoguin
07078eb47b
Fix a test listener not being stopped 2018-10-31 09:25:19 +01:00
Loïc Hoguin
122faedc25
Initial support for the PROXY protocol header
Depend on Ranch master for now since it isn't in any release yet.
2018-10-30 23:30:54 +01:00
Loïc Hoguin
a002df4560
Fix the sys trap_exit tests
The processes go down slower now so that caused intermittent
issues.
2018-10-28 17:11:52 +01:00
Loïc Hoguin
d4129e6305
Exit gracefully on parent exit/sys:terminate/2,3 2018-10-28 10:20:43 +01:00
Loïc Hoguin
e1d970b5eb
Switch cowboy_http2 to the new cow_http2_machine
The new module is a merge of the Cowboy and Gun HTTP/2
state machines. Using a common code will help future
developments rather than duplicating the work.

A notable change is in how streams are terminated
when the handler stops before the body is sent. The
cowboy_stream:terminate function is now called only
after the body has been sent fully (or the stream
is reset in-between), not when the stop command is
returned. This will most likely have an impact on
metrics but will be closer to reality.

I had to comment a broken test in rfc7231_SUITE that
was cheating, cheating is no longer possible.

This depends on Cowlib master for the time being. A
new Cowlib version will be released once both Cowboy
and Gun are ported to use cow_http2_machine and I'm
satisfied with it.
2018-10-26 10:23:28 +02:00
Loïc Hoguin
3c8e6cf819
Use gun:info instead of hacks for test socket operations 2018-09-26 17:17:25 +02:00
Loïc Hoguin
bc43fca9e6
Fix stream_handler_SUITE test failures due to compression
We always compress when streaming the body back to the client
regardless of the size actually streamed.
2018-09-23 14:10:04 +02:00
Loïc Hoguin
f63609cb9c
Correct two tests that introspect the Gun state
It has changed in Gun 1.2.
2018-09-23 14:04:47 +02:00
Loïc Hoguin
a0f8d9b8b8
Rename the HTTP/2 Websocket test suite to rfc8441_SUITE 2018-09-21 16:12:19 +02:00
Loïc Hoguin
f810d8dd64
Add the {active, boolean()} Websocket command
This command is currently not documented. It allows disabling
the reading of incoming data from the socket, and can be used
as a poor man's flow control.
2018-09-21 15:01:57 +02:00
Loïc Hoguin
b56a5a1d60
Do not send a 101 after a final response in switch_protocol 2018-09-12 16:16:29 +02:00
Loïc Hoguin
8390b04f7a
Swap the ws and autobahn test groups to run autobahn last
If there's an error it makes sense to have feedback as early
as possible.
2018-09-11 14:45:41 +02:00
Loïc Hoguin
8404b1c908
Add a commands-based interface to Websocket handlers
This feature is currently experimental. It will become the
preferred way to use Websocket handlers once it becomes
documented.

A commands-based interface enables adding commands without
having to change the interface much. It mirrors the interface
of stream handlers or gen_statem. It will enable adding
commands that have been needed for some time but were not
implemented for fear of making the interface too complex.
2018-09-11 14:33:58 +02:00
Loïc Hoguin
4b385749f2
Add cowboy_req:read_and_match_urlencoded_body/2,3 2018-09-07 13:56:12 +02:00
Loïc Hoguin
0a5fadc60b
Improve errors for when the ProvideCallback is missing 2018-08-13 17:23:48 +02:00
Loïc Hoguin
ef426e0ff4
Fix the infinity timeout tests
Make sure the test fails when the code is incorrect.
2018-08-13 11:10:49 +02:00
Loïc Hoguin
b0774f7069
Move some test functions off to ct_helper 2018-08-13 11:10:49 +02:00
Bing Han
e9fd2925ae
Fix cancelling undefined settings timer
when settings_timeout is infinity
2018-08-13 11:10:49 +02:00
Loïc Hoguin
0fb68ec07f
Add test cases for cowboy_req:stream_events 2018-06-27 13:40:11 +02:00
Loïc Hoguin
7867e435fe
Fix tests for most recent Gun 2018-06-26 10:32:33 +02:00
Eric Meadows-Jönsson
f08f4610a0
Add streaming without chunking for HTTP/1.1
If content-length is set in the response headers
we can skip chunked transfer-encoding.
2018-06-25 11:44:38 +02:00
Loïc Hoguin
1a6407d8a8
Add a test for an empty host header in rfc7230 2018-06-04 14:33:24 +02:00
Loïc Hoguin
633aa89f00
Fix intermittent test failures in rfc7540_SUITE 2018-05-22 13:05:15 +02:00
Loïc Hoguin
dc58eea9b4
Ensure tests in rfc7540_SUITE can be repeated 2018-05-22 13:04:42 +02:00
Loïc Hoguin
6e00600d7d
Fix intermittent failure of max_frame_size_sent test 2018-05-20 18:17:49 +02:00
Loïc Hoguin
338b1ca3f7
Remove two broken absolute URI tests from old_http_SUITE 2018-05-18 18:46:36 +02:00
Loïc Hoguin
5d1cf36358
Remove the trailer header from HTTP/1.1 response if no TE 2018-05-18 18:38:38 +02:00
Loïc Hoguin
5229d790fb
Don't send transfer-encoding when streaming 204 responses 2018-05-18 18:38:26 +02:00
Loïc Hoguin
07d454bdb7
Improve the limit_requests_keepalive test
We now check that the connection gets closed.
2018-05-18 16:56:54 +02:00
Loïc Hoguin
6c04875111
Fix the ignore_requests_after_response_connection_close test
It was not working at all.
2018-05-18 15:17:07 +02:00