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

2002 commits

Author SHA1 Message Date
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
3ae228897a
Don't log stray messages for lingering HTTP/2 streams 2019-10-10 17:06:24 +02:00
Loïc Hoguin
525eeeecc9
Cowboy 2.7.0 2019-10-10 16:15:51 +02:00
Loïc Hoguin
a73004e966
Fix a number of low hanging todos 2019-10-10 16:04:28 +02:00
Loïc Hoguin
ecb39eea10
Newly documented cow_cookie:cookie_opts() is now a map 2019-10-10 14:52:02 +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
cc54c207e3
Implement flow control for HTTP/1.1
We now stop reading from the socket unless asked to,
when we reach the request body. The option
initial_stream_flow_size controls how much data
we read without being asked, as an optimization.
We may also have received additional data along
with the request headers.

This commit also reworks the timeout handling for HTTP/1.1
because the stray timeout message was easily reproducible
after implementing the flow control. The issue should be
gone for good this time.
2019-10-09 20:54:33 +02:00
Loïc Hoguin
0c4103984b
Add migration guide for Cowboy 2.7 2019-10-07 17:48:45 +02:00
Loïc Hoguin
b350180503
Add new stream handlers to the guide
Also link from the guide to manual pages.
2019-10-07 14:06:37 +02:00
Loïc Hoguin
80aef3cdaa
Document no date/server headers from response/headers commands 2019-10-07 13:45:07 +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
fad0ac8fb6
Document the set_options stream handler command 2019-10-07 12:07:23 +02:00
Loïc Hoguin
e25fb19bab
Document the log stream handler command 2019-10-07 11:58:45 +02:00
Loïc Hoguin
53bc54a860
Document the logger option 2019-10-07 11:43:44 +02:00
Loïc Hoguin
0342866c2e
Document cowboy_tracer_h 2019-10-07 10:43:22 +02:00
Loïc Hoguin
eaed063702
Document cowboy_metrics_h 2019-10-07 09:59:36 +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
2b38526351
Fix PUT when resource doesn't exist in flowchart
This required moving around a lot of things so hopefully I
did not add errors while doing so. Only time will tell.

Also add the 415 that can result from content_types_accepted.
2019-10-06 12:48:35 +02:00
Loïc Hoguin
62836cdddc
Document how to recover from cookie parsing errors 2019-10-06 10:18:16 +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
618c001291
Fix REST flowchart around 201 response for PUT
When the method is PUT we do not check the location header.
2019-10-05 11:39:53 +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
99df823cc3
Document stopping the listener in App:stop/1 2019-10-03 10:09:35 +02:00
Loïc Hoguin
e4a535cfa6
Fix another Dialyzer warning 2019-10-02 21:51:27 +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
8f6ee9c186
Make sure cowboy_http doesn't receive stray timeout messages 2019-10-02 16:59:41 +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
8e31548597
Fix a Dialyzer warning and improve some types 2019-10-02 12:01:40 +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
6ddabc2c21
Remove lingering_data tuple handling 2019-10-02 10:09:30 +02:00
Loïc Hoguin
cf84f59d9b
Add persistent_term support to the router 2019-09-28 15:40:41 +02:00
Loïc Hoguin
7bccad4d21
Only test on the latest release per OTP major version by default 2019-09-18 09:48:12 +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
Loïc Hoguin
e28a339ccd
Fix intermittent failures in sys_SUITE 2019-09-15 10:01:32 +02:00
Loïc Hoguin
49af57d546
Implement backpressure on cowboy_req:stream_body
This should limit the amount of memory that Cowboy is using
when a handler is sending data much faster than the network.

The new max_stream_buffer_size is a soft limit and only has
an effect when the cowboy_stream_h handler is used.
2019-09-14 18:21:05 +02:00
Loïc Hoguin
4427108b69
Improve the cowboy_static consistency across platforms
As a result we explictly reject path_info components that include
a forward slash, backward slash or NUL character. This only applies
to the [...] part of the path for dir/priv_dir configuration.

Also improve the tests so that they work on Windows.
2019-09-07 12:18:16 +02:00