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

42 commits

Author SHA1 Message Date
Loïc Hoguin
eef66e0928
Remove copyright years from all files except LICENSE 2025-02-17 15:00:02 +01:00
Loïc Hoguin
b36f064a91
Refresh copyright lines 2024-01-25 11:22:54 +01:00
Loïc Hoguin
6ef79ae410
Reject HTTP/1 requests with both content-length and transfer-encoding
The previous behavior was to accept them and drop the
content-length header as per the RFC recommendation.
But since this behavior is not normal it is safer to
just reject such requests than risk security issues.
2024-01-05 16:32:59 +01:00
Dmitri Vereshchagin
2558ba65ad
Fix shutdown for HTTP/1.1 pipeline
Sending extra response prevented by terminating all streams except
the one currently executing.

LH: Reworded some variables to make what happens more obvious.
2023-12-18 15:39:39 +01:00
Boris Pozdnyakov
e200272178
Reject invalid Connection header
LH: Small tweaks and added an HTTP/1.0 test.
2023-12-15 17:12:37 +01: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
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
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
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
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
84e474d212
Move one more old HTTP test case 2018-11-21 14:06:57 +01:00
Loïc Hoguin
dc52ebe440
Move some more tests out of the old HTTP test suite 2018-11-21 13:28:20 +01:00
Loïc Hoguin
9e852b4dd2
Move HTTP/1.0 tests from the old test suite to rfc7230 2018-11-20 23:10:51 +01:00
Loïc Hoguin
d2f367fba3
Use try..after in tests that start their own listeners 2018-11-19 09:29:21 +01:00
Loïc Hoguin
bed328b6c9
Use ?FUNCTION_NAME instead of ct_helper:name()
Cowboy is 19+ so it's OK to use it.
2018-11-19 09:05:34 +01:00
Loïc Hoguin
292039362a
Don't send the content-length header in empty 304 responses
It's OK to send it when set explicitly, as it can be set
to what the representation's size would have been.
2018-11-14 19:24:39 +01: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
5d1cf36358
Remove the trailer header from HTTP/1.1 response if no TE 2018-05-18 18:38:38 +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
Loïc Hoguin
95710da617
Comment out the origin_form_reject_if_connect test
We don't implement CONNECT yet so we unconditionally return
a 501 for these requests and that makes this test fail.
2018-05-18 15:16:14 +02:00
Loïc Hoguin
2f9ab91cdd
Add more validation of absolute-form request targets 2018-05-18 15:12:31 +02:00
Loïc Hoguin
5cb244eb7a
Remove more old_http_SUITE tests 2018-05-18 10:41:31 +02:00
Loïc Hoguin
bc39b433bb
Properly handle OPTIONS * requests
Support for these was broken during the development
of Cowboy 2.0. It is now fixed and better handled
than it ever was.
2017-12-06 14:05:30 +01:00
Loïc Hoguin
b0519af42a
Don't include a content-length in 204 responses 2017-11-29 21:38:10 +01:00
Loïc Hoguin
14b4afa669
Fix a test description 2017-11-29 18:07:38 +01:00
Loïc Hoguin
37d069cd51
Fix many rfc7230 tests that were echoing the URI 2017-11-29 18:07:23 +01:00
Loïc Hoguin
cf3ab5832a
Add nowarn_export_all to all test suites 2017-11-29 16:57:10 +01:00
Loïc Hoguin
e71733232e
Fix an rfc7230 test 2017-11-26 10:12:25 +01:00
Loïc Hoguin
7cd59f4367
Add more tests to the rfc7230 suite
A few more bugs detected. I'm at the end of the list. I need to
do a second reading, implement what I can, fix what I can and
then the suite should be complete.
2017-11-24 22:40:15 +01:00
Loïc Hoguin
aa453d4825
Add a few more rfc7230 tests
A few seems to highlight more bugs. They have no fix yet.
2017-11-24 19:08:49 +01:00
Loïc Hoguin
ce32e1985a
Add more tests to the rfc7230 suite
Found more bugs! Unfortunately no fix for them in this commit.
2017-11-24 00:16:19 +01:00
Loïc Hoguin
14173d5929
Move the pipeline test to the rfc7230 suite 2017-11-23 18:50:07 +01:00
Loïc Hoguin
c4e43ec26a
Add more rfc7230 tests and better handle bad chunk sizes
Bad chunk sizes used to be accepted and could result in
a badly parsed body or a timeout. They are now properly
rejected.

Chunk extensions now have a hard limit of 129 characters.
I haven't heard of anyone using them and Cowboy does not
provide an interface for them, but we can always increase
or make configurable if it ever becomes necessary (but
I honestly doubt it).

Also a test from the old http suite could be removed. Yay!
2017-11-22 23:10:00 +01:00
Loïc Hoguin
1af508c4cd
Add more rfc7230 tests and improve transfer-encoding
It's worth noting that transfer-encoding now takes precedence
over content-length as recommended by the RFC, so that when
both headers are sent we only care about transfer-encoding
and explicitly remove content-length from the headers.
2017-11-20 21:12:05 +01:00
Loïc Hoguin
62bf505d33
Add more rfc7230 tests
Also fixes the handling of the max_headers option for HTTP/1.1.
It is now a strict limit and not dependent on whether data is
already in the buffer.
2017-11-20 00:23:27 +01:00
Loïc Hoguin
f6539a9a68
Move tests from old http suite to rfc7230 suite 2017-11-19 22:04:48 +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
Loïc Hoguin
43adacc760
Welcome to 2017 2017-01-02 19:36:36 +01:00
Loïc Hoguin
b370442a63 Initial commit with connection/streams
Breaking changes with previous commit. This is a very large change,
and I am giving up on making a single commit that fixes everything.
More commits will follow slowly adding back features, introducing
new tests and fixing the documentation.

This change contains most of the work toward unifying the interface
for handling both HTTP/1.1 and HTTP/2. HTTP/1.1 connections are now
no longer 1 process per connection; instead by default 1 process per
request is also created. This has a number of pros and cons.

Because it has cons, we also allow users to use a lower-level API
that acts on "streams" (requests/responses) directly at the connection
process-level. If performance is a concern, one can always write a
stream handler. The performance in this case will be even greater
than with Cowboy 1, although all the special handlers are unavailable.

When switching to Websocket, after the handler returns from init/2,
Cowboy stops the stream and the Websocket protocol takes over the
connection process. Websocket then calls websocket_init/2 for any
additional initialization such as timers, because the process is
different in init/2 and websocket_*/* functions. This however would
allow us to use websocket_init/2 for sending messages on connect,
instead of sending ourselves a message and be subject to races.
Note that websocket_init/2 is optional.

This is all a big change and while most of the tests pass, some
functionality currently doesn't. SPDY is broken and will be removed
soon in favor of HTTP/2. Automatic compression is currently disabled.
The cowboy_req interface probably still have a few functions that
need to be updated. The docs and examples do not refer the current
functionality anymore.

Everything will be fixed over time. Feedback is more than welcome.
Open a ticket!
2016-03-05 20:20:42 +01:00
Loïc Hoguin
228cebaf04 Add rfc7230 test suite and update others to recent Gun
This is a large commit.

The rfc7230 test suite adds many tests from the RFC7230 document.

Gun has been updated quite a bit recently, which broke the Cowboy
suites. This is now fixed with this commit.

A new hook onfirstrequest has been added. It was very useful during
debugging of the test suites.

The initial process code has changed a little; more changes are
expected with the switch to maps for options.
2015-05-05 19:59:37 +03:00