| 1 |
[appendix] |
| 2 |
== Migrating from Cowboy 2.4 to 2.5 |
| 3 |
|
| 4 |
Cowboy 2.5 focused on making the test suites pass. A |
| 5 |
variety of new features, fixes and improvements have |
| 6 |
also been worked on. |
| 7 |
|
| 8 |
=== Features added |
| 9 |
|
| 10 |
* Add option `linger_timeout` to control how long |
| 11 |
Cowboy will wait before closing the socket when |
| 12 |
shutting down the connection. This helps avoid |
| 13 |
the TCP reset problem HTTP/1.1 suffers from. The |
| 14 |
default is now 1000 ms. |
| 15 |
|
| 16 |
* It is now possible to stream a response body |
| 17 |
without using chunked transfer-encoding when the |
| 18 |
protocol is HTTP/1.1. To enable this behavior, |
| 19 |
simply pass the content-length header with the |
| 20 |
expected size when initiating the streamed response. |
| 21 |
|
| 22 |
* Update Ranch to 1.6.2 |
| 23 |
|
| 24 |
* Update Cowlib to 2.6.0 |
| 25 |
|
| 26 |
=== Experimental features added |
| 27 |
|
| 28 |
* Websocket handlers now feature a commands-based interface. |
| 29 |
The return value from the callbacks can now take the form |
| 30 |
`{Commands, State}` where `Commands` can be frames to be |
| 31 |
sent or commands yet to be introduced. New commands will |
| 32 |
be available only through this new interface. |
| 33 |
|
| 34 |
* Add the `{active, boolean()}` Websocket handler command. |
| 35 |
It allows disabling reading from the socket when `false` |
| 36 |
is returned. `true` reenables reading from the socket. |
| 37 |
|
| 38 |
* Add the protocol option `logger` that allows configuring |
| 39 |
which logger module will be used. The logger module must |
| 40 |
follow the interface of the new `logger` module in Erlang/OTP 21, |
| 41 |
or be set to `error_logger` to keep the old behavior. A |
| 42 |
similar transport option exists in Ranch 1.6; both options |
| 43 |
are necessary to override Cowboy's default behavior completely. |
| 44 |
|
| 45 |
* Add the `{log, Level, Format, Args}` stream handler command. |
| 46 |
Making it a command rather than a direct call will simplify |
| 47 |
silencing particular log messages. |
| 48 |
|
| 49 |
=== New functions |
| 50 |
|
| 51 |
* The function `cowboy_req:stream_events/3` streams one or more |
| 52 |
text/event-stream events, encoding them automatically. |
| 53 |
|
| 54 |
* The functions `cowboy_req:read_and_match_urlencoded_body/2,3` |
| 55 |
can be used to read, parse and match application/x-www-form-urlencoded |
| 56 |
request bodies, in a similar way to `cowboy_req:match_qs/2`. |
| 57 |
|
| 58 |
=== Bugs fixed |
| 59 |
|
| 60 |
* Fix Erlang/OTP 21 warnings. |
| 61 |
|
| 62 |
* Ensure that the port number is always defined in the |
| 63 |
Req object. When it is not provided in the request, |
| 64 |
the default port number for the protocol being used |
| 65 |
will be set. |
| 66 |
|
| 67 |
* Ensure stream handlers can run after `cowboy_stream_h`. |
| 68 |
|
| 69 |
* Honor the SETTINGS_ENABLE_PUSH HTTP/2 setting: don't |
| 70 |
send PUSH frames to clients that disabled it. |
| 71 |
|
| 72 |
* Fix HTTP/2 `settings_timeout` option when the value |
| 73 |
is set to `infinity`. |
| 74 |
|
| 75 |
* HTTP/1.1 responses will no longer include a trailer header |
| 76 |
when the request had no te header. |
| 77 |
|
| 78 |
* HTTP/1.1 204 responses no longer send the transfer-encoding |
| 79 |
header when `cowboy_req:stream_reply/2,3` is used to send |
| 80 |
a response. |
| 81 |
|
| 82 |
* Improve HTTP/1.1 keepalive handling to avoid processing |
| 83 |
requests that follow the final request that will receive |
| 84 |
a response. |
| 85 |
|
| 86 |
* Improve the validation of HTTP/1.1 absolute-form requests. |
| 87 |
|
| 88 |
* When the `switch_protocol` is used after a response was |
| 89 |
sent, Cowboy will no longer attempt to send the 101 informational |
| 90 |
response for the protocol upgrade. This caused a crash of the |
| 91 |
connection previously. |
| 92 |
|
| 93 |
* Errors that occur when a callback returned by |
| 94 |
`content_types_provided` does not exist have been improved. |
| 95 |
|
| 96 |
* Prevent annoying error logs when using sendfile in |
| 97 |
Erlang/OTP 20 and lower. |
| 98 |
|
| 99 |
* Add missing frame types to `websocket_handle`. |
| 100 |
|
| 101 |
* A test suite has been added for RFC8297 to ensure that |
| 102 |
103 informational responses can be sent. |
| 103 |
|
| 104 |
* Numerous test cases have been fixed, improved or removed in order |
| 105 |
to make the test suites pass. Most of the failures were caused |
| 106 |
by broken tests. |
| 107 |
|
| 108 |
* Some misguiding or incorrect statements in the documentation |
| 109 |
have been removed or clarified. |