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

573 commits

Author SHA1 Message Date
Loïc Hoguin
03d306e6d1
Fix concurrent body streaming getting stuck with HTTP/2 2020-07-03 11:02:59 +02:00
Loïc Hoguin
39b2816255
204 and 304 responses must not include a body
When calling cowboy_req:reply/4 with a body a crash will occur
resulting in a 500 response. When calling cowboy_req:stream_reply/2,3
and then attempting to send a body a crash will occur.
2020-05-20 13:41:05 +02:00
Loïc Hoguin
8337aca4d3
Increase the default max_keepalive HTTP option to 1000
100 is very low for current deployments. 1000 is more
appropriate as a default value.
2020-05-20 11:08:58 +02:00
Loïc Hoguin
4edc39b003
Don't stop listeners that don't exist in static_handler_SUITE 2020-05-20 11:08:24 +02:00
Loïc Hoguin
0d0e7d164c
Increase the timetrap timeout in req_SUITE on Windows
Still seeing intermittent failures on Windows due to
timetrap so let's see if doubling the timeout again helps.
2020-04-08 10:28:27 +02:00
Loïc Hoguin
f79d60e0c7
Get rid of timeouts in metrics_SUITE
Again to avoid intermittent issues.
2020-04-08 10:28:11 +02:00
Loïc Hoguin
b339713461
Allow {error, enotconn} as test success in security_SUITE
This happens from time to time on Windows and is partially
due to how the test is written.
2020-04-07 10:18:29 +02:00
Loïc Hoguin
e51ac66728
Rely on timetrap timeouts for tracer_SUITE 2020-04-06 20:14:31 +02:00
Loïc Hoguin
8cba8c3c68
NO_PARALLEL=1 will disable (most) parallel testing
This is to make up for very slow or low resource environments,
like the FreeBSD CI environment currently.
2020-04-06 16:39:28 +02:00
Loïc Hoguin
5203ee6a84
Increase the req_SUITE timetrap timeout on Windows
The local network is much slower so the tests take longer there.
2020-04-06 12:27:41 +02:00
Loïc Hoguin
cc8a2e4257
Reduce the pipeline test body sizes to avoid filling send buffers
This causes the test to get stuck because both the client and
server end up waiting in Transport:send for the other side to
read data from the socket.
2020-04-05 16:28:54 +02:00
Loïc Hoguin
4274f077a6
Disable ws_SUITE:unlimited_connections on Windows 2020-04-02 17:36:03 +02:00
Loïc Hoguin
3f37985d2c
Skip ws_SUITE:unlimited_connections when ulimit -n is too low 2020-04-02 16:23:36 +02:00
Loïc Hoguin
962d715ad4
Make req_SUITE:read*_body_urlencoded_too_long tests reliable 2020-04-02 15:46:38 +02:00
Loïc Hoguin
0143d9e5a9
Use infinity timeout for gun:await* calls in req_SUITE 2020-04-02 14:57:10 +02:00
Loïc Hoguin
789768e8d3
Rework the req_SUITE:read_body_period test
To avoid intermittent test failures. We only want to make
sure the function eventually returns so we don't need to
use timeouts in the test itself, or check exactly what was
read.
2020-04-02 14:01:26 +02:00
Loïc Hoguin
2b65b575c6
Change a few flaky tests to use timetrap and infinity timeouts
The experiment was successful in Gun, let's see if it helps
with Cowboy as well.
2020-04-01 21:11:59 +02:00
Loïc Hoguin
a8a2689727
Fix h2spec "invalid preface sequence" test
Introduce a currently undocumented option to allow disabling
cowboy_http when using a clear listener.
2020-04-01 18:02:59 +02:00
Loïc Hoguin
bcef70818b
Fix the req_SUITE:parse_cookie test
We now allow spaces in cookie names.
2020-03-30 17:46:42 +02:00
Loïc Hoguin
6ad842a742
Increase the default max_received_frame_rate
Allow 10000 frames every 10 seconds instead of just 1000,
as the limit was too quickly reached in some deployments.
2020-03-29 13:51:21 +02:00
Loïc Hoguin
8fc3da2fc3
Fix HTTP/1.1 bug when a flow command is returned after fin
This resulted in a badarith error due to the current flow being
set to infinity when the body has been fully read. A test case
has been added reproducing the issue.
2020-02-07 11:32:15 +01:00
Loïc Hoguin
47ecfd7318
Add a test confirming push requests have no body 2020-02-05 18:06:00 +01:00
Loïc Hoguin
752297b153
Fix bugs related to HTTP/1.1 pipelining
The flow control is now only set to infinity when we are
skipping the request body of the stream that is being
terminated. This fixes a bug where it was set to infinity
while reading a subsequent request's body, leading to a
crash.

The timeout is no longer reset on stream termination.
Timeout handling is already done when receiving data
from the socket and doing a reset on stream termination
was leading to the wrong timeout being set or the right
timeout being reset needlessly.
2020-01-17 11:42:28 +01:00
Marcos Ferreira
3b85b808ae
Ignore malformed accept-encoding headers in cowboy_compress_h 2019-12-31 13:48:05 +01:00
Tony Han
43f1754f33
Test trailers bug when there are data frames in queue 2019-12-31 11:06:31 +01:00
Loïc Hoguin
63b17e4edf
Use /long_polling for rfc7540 tests that reset the stream 2019-10-10 17:06:59 +02:00
Loïc Hoguin
d52e84bdd9
Add shutdown_reason Websocket command
This allows changing the normal exit reason of Websocket
processes, providing a way to signal other processes of
why the exit occurred.
2019-10-10 11:33:35 +02:00
Loïc Hoguin
2e8fcb9a9e
Add cowboy_req:cast/2
Better than sending messages manually.
2019-10-07 13:25:49 +02:00
Loïc Hoguin
5cdf78fd57
Fix an intermittent test issue 2019-10-07 12:18:03 +02:00
Loïc Hoguin
3977f2b96f
Document the commands based Websocket interface
The old interface with ok|reply|stop tuples is deprecated.
2019-10-06 16:51:27 +02:00
Loïc Hoguin
3e23aff1d1
Add Websocket option validate_utf8
This allows disabling the UTF-8 validation check
for text and close frames.
2019-10-05 17:32:50 +02:00
Loïc Hoguin
c50d6aa09c
Don't discard data following a Websocket upgrade request
While the protocol does not allow sending data before
receiving a successful Websocket upgrade response, we
do not want to discard that data if it does come in.
2019-10-05 13:04:21 +02:00
Loïc Hoguin
03dac1486d
Add cowboy_req:filter_cookies/2 2019-10-05 11:23:57 +02:00
Loïc Hoguin
5ffb4f98e0
Make cowboy_compress_h add vary: accept-encoding 2019-10-04 13:32:35 +02:00
Loïc Hoguin
1a9e62ae2a
Improve some early_error tests 2019-10-04 11:57:29 +02:00
Loïc Hoguin
28aee1f272
Document media type wildcard in content_types_accepted 2019-10-03 16:20:29 +02:00
Loïc Hoguin
1ba48c58b1
Make stream_error early_error reasons consistent
Now both HTTP/1.1 and HTTP/2 follow the documented format.
HTTP/1.1 was including an extra element containing the
StreamID before, which was unnecessary because it is also
given as argument to the callback.

HTTP/2 early_error will now include headers in its PartialReq.
2019-10-03 16:04:17 +02:00
Loïc Hoguin
57badc9082
Add HTTP/2 tests with responses with HTTP/1.1 specific headers 2019-10-03 11:56:57 +02:00
Loïc Hoguin
eaa052616f
Ensure we can stream the response body from any process 2019-10-02 20:30:32 +02:00
Loïc Hoguin
20660d7566
Ensure we can read the request body from any process 2019-10-02 19:12:05 +02:00
Loïc Hoguin
f673e191b3
Add {set_options, #{metrics_user_data := Map}}
This allows giving custom metadata to the metrics stream handler.
This can be useful to for example provide the name of the
module handling the request which is only known after routing.
But any user data is allowed.

When called multiple times the user data maps are merged.
2019-10-02 15:23:23 +02:00
Loïc Hoguin
a14ecf19c6
Add more HTTP/1.1 header parsing tests
Fix a case where Cowboy was waiting for more data that simply
did not come. Now Cowboy will generate an error immediately
when a header line has no colon separator.

These test cases come from known request smuggling attack
vectors. Cowboy was not vulnerable to any of them.
2019-10-02 13:31:13 +02:00
Loïc Hoguin
ab44985a9e
Fix HTTP/2 CVEs
A number of HTTP/2 CVEs were documented recently:

  https://www.kb.cert.org/vuls/id/605641/

This commit, along with a few changes and additions in Cowlib,
fix or improve protection against all of them.

For CVE-2019-9511, also known as Data Dribble, the new option
stream_window_data_threshold can be used to control how little
the DATA frames that Cowboy sends can get.

For CVE-2019-9516, also known as 0-Length Headers Leak, Cowboy
will now simply reject streams containing 0-length header names.

For CVE-2019-9517, also known as Internal Data Buffering, the
backpressure changes were already pretty good at preventing this
issue, but a new option max_connection_buffer_size was added for
even better control over how much memory we are willing to allocate.

For CVE-2019-9512, also known as Ping Flood; CVE-2019-9515, also
known as Settings Flood; CVE-2019-9518, also known as Empty Frame
Flooding; and similar undocumented scenarios, a frame rate limiting
mechanism was added. By default Cowboy will now allow 1000 frames
every 10 seconds. This can be configured via max_received_frame_rate.

For CVE-2019-9514, also known as Reset Flood, another rate limiting
mechanism was added and can be configured via max_reset_stream_rate.
By default Cowboy will do up to 10 stream resets every 10 seconds.

Finally, nothing was done for CVE-2019-9513, also known as Resource
Loop, because Cowboy does not currently implement the HTTP/2
priority mechanism (in parts because these issues were well known
from the start).

Tests were added for all cases except Internal Data Buffering,
which I'm not sure how to test, and Resource Loop, which is not
currently relevant.
2019-10-02 10:44:45 +02:00
Loïc Hoguin
e1d4524118
Update gun_down messages in test suites 2019-10-02 10:10:43 +02:00
Loïc Hoguin
cf84f59d9b
Add persistent_term support to the router 2019-09-28 15:40:41 +02:00
Loïc Hoguin
d143235a79
Fix closing of connection on response_body_too_small 2019-09-16 11:34:51 +02:00
Loïc Hoguin
8452df0617
Split up urlencoded tests to speed up req_SUITE 2019-09-15 21:49:45 +02:00
Loïc Hoguin
da5487b5a3
Skip req_SUITE:read_body_mtu on Windows
On Windows the loopback MTU seems to be set to 0xFFFFFFFF
(basically no limit) which makes the test irrelevant.
2019-09-15 21:34:14 +02:00
Loïc Hoguin
2888e9e6ef
Increase the period for req_SUITE:read_body_period
This should increase the likelihood of the test succeeding
on slower systems when run over TLS.
2019-09-15 16:30:09 +02:00
Loïc Hoguin
ea976f02e0
Fix h2spec_SUITE init_per_suite return values 2019-09-15 11:18:35 +02:00