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

1091 commits

Author SHA1 Message Date
Loïc Hoguin
5bece31775
Add missing logger spec for cowboy_http2 opts 2018-07-09 10:08:48 +02:00
Loïc Hoguin
a76c32db5e
Introduce undocumented option logger
This commit reworks the logging that Cowboy does via
error_logger to make the module that will do the actual
logging configurable.

The logger module interface must be the same as logger
and lager: a separate function per log level with the
same log levels they support.

The default behavior remains to call error_logger,
although some messages were downgraded to warnings
instead of errors. Since error_logger only supports
three different log levels, some messages may get
downgraded/upgraded depending on what the original
log level was to make them compatible with error_logger.

The {log, Level, Format, Args} command was also
added to stream handlers. Stream handlers should
use this command to log messages because it allows
writing a stream handler to intercept some of those
messages and extract information or block them as
necessary.

The logger option only applies to Cowboy itself,
not to the messages Ranch logs, so more work remains
to be done in that area.
2018-06-28 17:10:18 +02:00
Loïc Hoguin
34f57ebbd3
Make sure cowboy_stream_h calls subsequent stream handlers 2018-06-27 18:07:58 +02:00
Loïc Hoguin
68ede9cfe4
Disable warnings for erlang:get_stacktrace/0 in OTP-21+ 2018-06-27 17:52:25 +02:00
Loïc Hoguin
5001fcbc34
Add missing frame types to websocket_handle specs/docs
Thanks Artem.
2018-06-26 10:59:22 +02:00
Loïc Hoguin
b2b5e3a01a
Add an undocumented stream_events function
I will test it on a private project before settling on it.
2018-06-25 15:56:29 +02:00
Eric Meadows-Jönsson
f08f4610a0
Add streaming without chunking for HTTP/1.1
If content-length is set in the response headers
we can skip chunked transfer-encoding.
2018-06-25 11:44:38 +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
5229d790fb
Don't send transfer-encoding when streaming 204 responses 2018-05-18 18:38:26 +02:00
Loïc Hoguin
763eef4e46
Do not process HTTP/1.1 requests coming in after the last 2018-05-18 17:10:54 +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
fb5a261614
Move a router test from old_http_SUITE to cowboy_router 2018-05-17 17:53:16 +02:00
Loïc Hoguin
0e629f4799
Add option linger_timeout to cowboy_http 2018-05-16 16:01:30 +02:00
Loïc Hoguin
cc49659f93
Wrap the sendfile call in a try/catch for HTTP
This should reduce the amount of noise in RabbitMQ.
2018-05-16 12:28:23 +02:00
Loïc Hoguin
ae6c787062
Honor the SETTINGS_ENABLE_PUSH from clients
This fixes curl when fetching resources that use push.
2018-05-16 11:00:25 +02:00
Loïc Hoguin
d732e74dd5
Use default port when not given in :authority 2018-05-16 10:42:25 +02:00
Loïc Hoguin
93e8744e22
Move cowboy_iolists to Cowlib as cow_iolists
Depend on Cowlib master for the moment.
2018-05-07 15:33:11 +02:00
Loïc Hoguin
28d3515d71
Remove a bunch of todos 2018-04-30 18:39:27 +02:00
Loïc Hoguin
8d1f468ac0
Reject HTTP/2 requests with a body size different than content-length 2018-04-30 13:47:33 +02:00
Loïc Hoguin
84b4128d06
Receive and ignore HTTP/2 request trailers if any
This is a first step toward properly supporting request trailers.
2018-04-29 17:39:48 +02:00
Loïc Hoguin
2db5ffbf84
Add SETTINGS ack timeout and option settings_timeout 2018-04-28 11:00:50 +02:00
Loïc Hoguin
3d6bb01d5f
Reject WINDOW_UPDATE frames sent after an RST_STREAM 2018-04-27 20:45:34 +02:00
Loïc Hoguin
9a29aea148
Add options controlling maximum h2 frame sizes 2018-04-27 17:58:37 +02:00
Loïc Hoguin
d38d86c4a9
Add options controlling initial control flow windows 2018-04-26 22:08:05 +02:00
Loïc Hoguin
7373822b86
Add the max_concurrent_streams h2 option 2018-04-25 21:32:58 +02:00
Loïc Hoguin
8f4adf437c
Add options to control h2's SETTINGS_HEADER_TABLE_SIZE 2018-04-25 16:55:52 +02:00
Loïc Hoguin
8b9a09c9fe
HTTP/2 informational responses don't end the stream 2018-04-23 15:49:34 +02:00
Loïc Hoguin
9af8b0d23a
Add missing enable_connect_protocol in typespecs 2018-04-23 14:34:53 +02:00
Loïc Hoguin
adf1a40287
Fix Dialyzer warnings 2018-04-04 17:34:10 +02:00
Loïc Hoguin
bbfc1569cc
Add initial implementation of Websocket over HTTP/2
Using the current draft:

  https://tools.ietf.org/html/draft-ietf-httpbis-h2-websockets-01
2018-04-04 17:23:37 +02:00
Kirill Kinduk
4c34774b7e
Add max_frame_size option for websocket handlers
Option allows to limit a frame by size before decoding its payload.

LH: I have added a test for when the limit is reached on a nofin
fragmented frame (the last commit addressed that case but it had
no test). I have fixed formatting and other, and changed the
default value to infinity since it might otherwise be incompatible
with existing code. I also added documentation and a bunch of other
minor changes.
2018-03-28 16:58:02 +02:00
Loïc Hoguin
5964273cc4
Fix the flushing of messages when switching to Websocket
We now flush messages that are specific to cowboy_http only.

Stream handlers should also flush their own specific messages
if necessary, although timeouts will be flushed regardless
of where they originate from.

Also renames the http_SUITE to old_http_SUITE to distinguish
new tests from old tests. Most old tests need to be removed
or converted eventually as they're legacy tests from Cowboy 1.0.
2018-03-26 18:53:07 +02:00
Loïc Hoguin
4d5174632c
Add initial support for system messages in cowboy_loop 2018-03-23 18:33:16 +01:00
Loïc Hoguin
21c9c66971
Merge the two separate receive loops in cowboy_websocket
Also rename a bunch of functions to make the code easier to read.
2018-03-23 16:32:53 +01:00
Loïc Hoguin
6945882cd3
Fix a Dialyzer warning 2018-03-14 17:43:13 +01:00
Bartek Walkowicz
2131709328
Add case for handling infinity for idle/request_timeout
Currently cowboy assumes that idle_timeout or request_timeout is
a number and always starts timers. Similar situation takes place
in case of preface_timeout for http2. This commit adds case for
handling infinity as a timeout, allowing to not start mentioned
timers.
2018-03-14 17:15:06 +01:00
Loïc Hoguin
f9092126fa
Handle system messages in cowboy_websocket 2018-03-13 11:19:13 +01:00
Loïc Hoguin
b9c8d86502
Handle supervisor calls properly everywhere 2018-03-13 10:40:14 +01:00
Loïc Hoguin
19054e40e0
Fix crash in cowboy_http2 when content-length is invalid 2018-02-28 16:18:29 +01:00
Loïc Hoguin
819a47a220
Fix sending HTTP/2 bodies as iolists out of order 2018-01-24 11:44:03 +01:00
Loïc Hoguin
e09ae60d5b
Fix an unused variable warning 2018-01-23 16:29:25 +01:00
Loïc Hoguin
482de55a96
Fix a miscount of output flow control window for HTTP/2
The miscount occurred because of a faulty iolist split function.
The bug should now be corrected, a PropEr test has been added
and a regression test has also been added.
2018-01-23 16:14:18 +01:00
Loïc Hoguin
3a7b411143
Don't crash in delete_resp_header if no resp headers are set 2018-01-22 14:00:05 +01:00
Paul Fisher
82cd22a88b
Allow colon within path segments
Allow `cowboy_router:compile` to handle colon characters within
path segments, rather than exiting with `badarg`.  This is allowed
via RFC 7230 2.7 -> [RFC 3986 3.3](https://tools.ietf.org/html/rfc3986#section-3.3):

```
      segment       = *pchar
      segment-nz    = 1*pchar
      segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
                    ; non-zero-length segment without any colon ":"

      pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
```
2018-01-16 11:24:49 +01:00
Loïc Hoguin
34473bc247
Fix Dialyzer warnings 2017-12-13 12:40:00 +01:00
Loïc Hoguin
576e2d2111
Don't badmatch on HTTP/2 preface's Transport:send
Send errors produce annoying logs and we notice the connection
is gone later on anyway.
2017-12-12 16:57:05 +01:00
Loïc Hoguin
eafca21198
Fix HTTP/1.1 pipelining
Cases where a request body was involved could sometimes
fail depending on timing. Also fix all of the old
http_SUITE tests.
2017-12-12 11:37:48 +01:00
Loïc Hoguin
17719a136d
Add the few remaining tests to the rfc7231 test suite 2017-12-08 20:38:31 +01:00
Loïc Hoguin
b000d53855
Add more rfc7231 tests and a new max_skip_body_length option
The option controls how much body we accept to skip for HTTP/1.1
connections when the user code did not consume the body fully.
It defaults to 1MB.
2017-12-07 22:33:52 +01:00
Loïc Hoguin
c2b813684e
Send a 426 when Websocket is required and client didn't upgrade 2017-12-06 17:31:32 +01:00