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

532 commits

Author SHA1 Message Date
Loïc Hoguin
6cc162583d
Keep the state returned by the tracer callback
It was mistakenly discarded.
2017-11-10 14:59:11 +00:00
Loïc Hoguin
da304799fe
Add a terminate event to the tracer and more tests 2017-11-03 17:52:18 +00:00
Loïc Hoguin
af58babd94
Fix stream_handler_SUITE test failures 2017-11-01 19:24:42 +00:00
Loïc Hoguin
5bb6438e10
Don't crash when cowboy_clock is not running
This can happen normally when Cowboy is restarted, for example.
Instead of failing requests when that happens, we degrade
gracefully and do a little more work to provide the current
date header.
2017-11-01 17:06:37 +00:00
Loïc Hoguin
836342abb8
Add {switch_handler, Module} return value to cowboy_rest
Also {switch_handler, Module, Opts}.

Allows switching to a different handler type. This is
particularly useful for processing most of the request
with cowboy_rest and then streaming the response body
using cowboy_loop.
2017-11-01 16:27:26 +00:00
Loïc Hoguin
83bd8bc935
Fix two edge cases for cowboy_req:stream_body
Sending data of size 0 with the fin flag set resulted in nothing
being sent to the client and still considering the response to
be finished for HTTP/1.1.

For both HTTP/1.1 and HTTP/2, the final chunk of body that is
sent automatically by Cowboy at the end of a response that the
user did not properly terminate was not passing through stream
handlers. This resulted in issues like compression being incorrect.

Some tests still fail under 20.1.3. They are due to recent zlib
changes and should be fixed in a future patch release. Unfortunately
it does not seem to be any 20.1 version that is safe to use for
Cowboy, although some will work better than others.
2017-11-01 15:33:10 +00:00
Loïc Hoguin
ad9ab51648
Add some todos 2017-10-31 17:15:11 +00:00
Loïc Hoguin
4e85ad76a0
Fix a unused warning 2017-10-31 16:50:17 +00:00
Loïc Hoguin
d41f2914b0
Fix broken tests in loop_handler_SUITE 2017-10-31 16:49:48 +00:00
Loïc Hoguin
fb13e5c9e9
Fix the static_handler test suite
Bad requests correctly return 400, not 500.
2017-10-31 15:41:25 +00:00
Loïc Hoguin
a97640d56d
Add informational responses to metrics 2017-10-31 15:04:00 +00:00
Loïc Hoguin
217fac7f44
Handle expect: 100-continue request headers
The 100 continue response will only be sent if the client
has not sent the body yet (at all), if the connection is
HTTP/1.1 or above and if the user has not sent it yet.

The 100 continue response is sent when the user calls
read_body and it is cowboy_stream_h's responsibility
to send it. This means projects that don't use the
cowboy_stream_h stream handler will need to handle the
expect header themselves (but that's okay because they
might have different considerations than normal Cowboy).
2017-10-30 16:21:25 +00:00
Loïc Hoguin
f3d6b05b86
Add cowboy_req:inform/2,3
User code can now send as many 1xx responses as necessary.
2017-10-29 21:03:04 +00:00
Loïc Hoguin
f4331f7c16
Add cowboy_tracer_h stream handler
Another experimental stream handler. It enables tracing for
the connection process and any children processes based on
the matching of the request. It can be used to do ad-hoc
tracing by sending a specific header, path, method or other.

It is meant to be used both for tests and production. Some
configuration scenarios are NOT safe for production, beware.

It's important to understand that, at this time, tracing
is enabled on the scale of the entire connection including
any future request processes. Keep this in mind when trying
to use it in production. The only way to stop tracing is
by having the callback function exit (by calling exit/1
explicitly). This can be done after a certain number of
events for example. Tracing can generate a lot of events,
so it's a good idea to stop after a small number of events
(between 1000 and 10000 should be good) and to avoid tracing
the whole world.

Documentation will follow at a later time.
2017-10-27 17:18:28 +01:00
Loïc Hoguin
ef58e15547
Introduce cowboy_req:sock/1 and cowboy_req:cert/1
To obtain the local socket ip/port and the client TLS
certificate, respectively.
2017-10-25 21:03:26 +01:00
Loïc Hoguin
e7114577bb
Fix a bug in HTTP/2 where connection gets closed prematurely
When the user code was sending a response fully without reading
the request body, the connection could get closed when receiving
DATA frames for that body. We now ask the client to stop sending
data via a NO_ERROR RST_STREAM, and linger any stream that has
been reset so that we can skip any pending frames from that
stream.

This fixes a number of intermittent failures in req_SUITE, which
now passes reliably.

In addition a small number of rfc7540_SUITE test cases have been
corrected as they were incorrect.
2017-10-23 14:49:33 +01:00
Loïc Hoguin
133d359674
Add a metrics test for switching to Websocket 2017-10-22 14:54:13 +01:00
Loïc Hoguin
4bebe39975
Ensure stream terminate is called when switching protocols 2017-10-22 14:53:04 +01:00
Loïc Hoguin
debaecd49a
Add a test for stream_reply metrics 2017-10-21 21:03:06 +01:00
Loïc Hoguin
c4651261b6
Add a test for early_error metrics 2017-10-21 14:56:28 +01:00
Loïc Hoguin
2a905e9bda
Add a metrics test when the handler didn't send anything
Also fix a test group to use h2 instead of HTTP/1.1.
2017-10-21 13:12:36 +01:00
Loïc Hoguin
1ef5a1c45b
Add a test for metrics with a request body 2017-10-20 18:00:40 +01:00
Loïc Hoguin
4211ea41bd
Add experimental metrics stream handler
It collects metrics and passes them to a configurable callback
once the stream terminates. It will be documented in a future
release. More tests incoming.
2017-10-20 14:46:10 +01:00
Loïc Hoguin
c602871f86
Fix HTTP/1.1 stopping streams too early
It is possible in some cases to move on to the next request
without waiting, but that can be done as an optimization
later on if necessary.
2017-10-20 13:16:04 +01:00
Loïc Hoguin
6fc05a6d64
Make sure a path parsing error in the router gives a 400 2017-10-03 00:30:15 +02:00
Loïc Hoguin
9317751cb3
Fix cowboy:set_env when the env value is missing 2017-10-02 16:19:13 +02:00
Jeffrey Griffin
6460e9d2d2
Fix infinite loop on incomplete multipart body
I have amended a lot of changes from the original commit
to make it behave as expected, including returning a 400
error. LH
2017-10-02 13:28:43 +02:00
Loïc Hoguin
fda2d150db
Fix error response when constraint validation fails 2017-09-27 16:20:38 +02:00
Loïc Hoguin
11ae407eed
Ensure the behavior on stream handler crash is consistent
Also corrects the lack of error response when HTTP/1.1 is used.
2017-09-27 14:17:27 +02:00
Loïc Hoguin
3cbf885961
Improve how we detect request errors
When the request process exits with a {request_error, Reason, Human}
exit reason, Cowboy will return a 400 status code instead of 500.
Cowboy may also return a more specific status code depending on
the error. Currently it may also return 408 or 413.

This should prove to be more solid that looking inside the stack
trace.
2017-09-14 13:42:17 +02:00
Loïc Hoguin
9f5a1803da
Add tests for direct Req access 2017-09-05 15:28:11 +02:00
Loïc Hoguin
4fd6e2f7cd
Accept sendfile tuple with 0 length in cowboy_req
This will result in no data being sent. It's simply easier to
do this than to have to handle 0 size cases in user code.
2017-09-04 20:48:07 +02:00
Loïc Hoguin
0995fc99e0
Add a static handler test with an empty file 2017-09-04 18:00:56 +02:00
Loïc Hoguin
0828e0b9ce
Alphabetical order some tests 2017-09-04 15:48:46 +02:00
Loïc Hoguin
a2facaf2da
Add tests for the streams shutdown mechanism 2017-08-14 17:17:44 +02:00
Loïc Hoguin
7d9f6611ae
Fix the remaining http_SUITE test cases 2017-07-14 19:09:42 +02:00
Loïc Hoguin
23fcfe9eea
Fix more of the older tests
The Cowboy behavior has changed a little and gives more
accurate error responses now. And in some cases, successes.
2017-07-13 00:20:56 +02:00
Loïc Hoguin
ddb0c4f3b6
Fix a few of the older tests 2017-07-12 19:40:52 +02:00
Loïc Hoguin
cf4d8166f8
Remove tests for set_resp_body with a stream fun 2017-07-12 19:25:56 +02:00
Loïc Hoguin
3c18585945
Remove any mention of the waiting_stream hack 2017-07-12 18:55:09 +02:00
Loïc Hoguin
acc5fed589
Remove the onresponse tests from http_SUITE 2017-07-12 18:36:49 +02:00
Loïc Hoguin
3eb7693e4f
Remove outdated multipart tests
They have equivalents in req_SUITE.
2017-06-28 13:07:44 +02:00
Loïc Hoguin
ec00e3d60e
Make cowboy_req:read_part return multipart headers as map 2017-06-09 16:57:11 +02:00
Loïc Hoguin
6f7b59886e
Remove NumAcceptors argument from start_clear/tls
They are now cowboy:start_clear/3 and cowboy:start_tls/3.
The NumAcceptors argument can be specified via the
num_acceptor transport option. Ranch has been updated
to 1.4.0 to that effect.
2017-06-07 15:15:54 +02:00
Loïc Hoguin
767da623f1
Fix terminate not being called on connection close in HTTP/1.1
Introduces the new stream_handler_SUITE test suite. More cases
will be added later on.
2017-06-02 12:31:00 +02:00
Loïc Hoguin
5f421f93bc
Introduce the req_filter Websocket option
This option allows customizing the compacting of the Req object
when using Websocket. By default it will keep most public fields
excluding headers of course, since those can be large.
2017-05-28 20:19:39 +02:00
Loïc Hoguin
8cb125dbb7
Fix a harmless warning in tests 2017-05-23 14:10:05 +02:00
Loïc Hoguin
9ef4536656
Add many tests for RFC7540 5.1 and 5.1.1 and related fixes 2017-05-23 14:09:38 +02:00
Loïc Hoguin
4048f16365
Add a test suite for h2spec
h2spec must be preinstalled on the machine and its location
pointed at by the H2SPEC environment variable.
2017-05-23 14:05:00 +02:00
Loïc Hoguin
f3e5f3e410
Preliminary h2 flow control support
Existing tests pass. A number of things remain to be done.
Has only been tested with Gun so far. Feedback welcome!
2017-05-19 20:18:00 +02:00