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

1639 commits

Author SHA1 Message Date
Loïc Hoguin
3da9a6eef9
Add a test for early errors that occur on the request-line 2017-11-20 16:26:37 +01:00
Loïc Hoguin
92672b49af
Queue HTTP/2 trailers when there's still data in the buffer 2017-11-20 15:46:23 +01:00
Loïc Hoguin
9969684035
Improve trailers test when no te header is sent 2017-11-20 12:17:44 +01:00
Loïc Hoguin
6c765101b1
Fix compression when trailers are sent 2017-11-20 12:13:57 +01:00
Loïc Hoguin
ecb2a735ef
Remove a useless todo 2017-11-20 11:28:22 +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
d7761b5259
Remove another test from the old http suite 2017-11-19 22:17:57 +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
8be803cb07
The static suite's large file is not created on Windows 2017-11-19 16:13:48 +01:00
Loïc Hoguin
344cec95b4
Add AUTO_CI_WINDOWS variable 2017-11-19 13:25:54 +01:00
Loïc Hoguin
185d928e1a
Remove duplicate /echo/body_qs tests from the old suite 2017-11-18 00:19:01 +01:00
Loïc Hoguin
bfe7f82812
Remove duplicate static handler tests from the old suite 2017-11-17 23:57:32 +01:00
Loïc Hoguin
435c541810
Move ci.erlang.mk to TEST_DEPS 2017-11-17 22:57:44 +01:00
Loïc Hoguin
aedd274e26
Disable the tracer suite when compiled natively 2017-11-17 22:55:56 +01:00
Loïc Hoguin
ce5ab4b49a
Initialize trace patterns only once
They are global for the node for all future call trace flags,
so it's not necessary to set them repeatedly with every request.

Doing it once at startup also ensures we can't have race
conditions when the user wants to change which trace patterns
should be used (because requests are concurrent and patterns
end up overwriting themselves repeatedly), and makes this
changing of trace patterns much more straightforward: the
user can just define the ones they want. The default function
traces everything.

In addition I have also added the tracer_flags option to make
the trace flags configurable, excluding the tracer pid.
2017-11-17 13:23:38 +01:00
Loïc Hoguin
52d869128b
Tweak the Makefile 2017-11-17 13:18:13 +01:00
Loïc Hoguin
39baed6c80
Add preliminary support for trailers in responses
This depends on changes in Cowlib that are only available on
master.
2017-11-15 14:58:49 +01:00
Loïc Hoguin
a1ad482eb4
Don't supervise the tracer process
If we do then we end up killing the tracer after the stream
terminates and this is not what we want. This prevents us from
getting useful information from requests that are still ongoing
(when they run concurrently) and completely prevents us from
tracing Websocket handlers.

I'm not the biggest fan of having unsupervised modules but if
this is properly documented there should be no problem.
2017-11-13 20:45:08 +01:00
Loïc Hoguin
6a8f9ebbb2
Fix packet being dropped when using switch_protocol
This only happens if the switch takes too long, and should not
happen unless a spawned process refuses to shut down immediately.
2017-11-13 18:03:25 +01:00
Loïc Hoguin
56dc5673d0
Use my new ci.erlang.mk plugin
Instead of tracking Erlang/OTP versions manually in each project,
I can just say OTP-19+ and let the plugin fill in the most recent
patch releases for each version. In addition I will configure the
CI commands to cleanup unneeded versions automatically.
2017-11-12 22:31:02 +01:00
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
32d9d494c7
Add a changelog for cowboy_rest 2017-11-09 13:23:31 +00:00
Loïc Hoguin
f200a6febd
Fix the introduction version for the new 2.1 functions 2017-11-09 13:21:29 +00:00
Loïc Hoguin
44d96ed9be
Add missing changes for 2.1 release 2017-11-09 12:05:22 +00:00
Loïc Hoguin
1e88324864
Update Cowboy to 2.1.0
Also add OTP-20.1.4 to CI.
2017-11-08 14:05:30 +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
5e88a9b394
Update Cowlib to 2.0.1 and fix OTP 20.1+ Websocket compression
Unfortunately compression will be disabled for 20.1, 20.1.1
and 20.1.2. In additiona I do not recommend 20.1.3 due to
issues inflating some specific sizes.
2017-11-01 15:41:52 +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
774824cd0f
Fix another warning 2017-10-31 22:36:37 +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
Luke Bakken
4090adaecc
Add migration note concerning multiple headers 2017-10-23 14:59:45 +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
76f4db863e
Fix sending of final chunk in HTTP/1.1
I broke this when fixing stream handlers earlier.
2017-10-21 21:01:40 +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
c62ce1c63e
Fix stream handler state being discarded on terminate
When we have to send a response before terminating a stream,
we call info. The state returned by this info call was
discarded when we called terminate after that. This commit
fixes it.

There are no tests for this, however the new metrics test
in the next commit requires the correct behavior so this
is ultimately covered.
2017-10-21 13:09:20 +01:00