| 1 |
[appendix] |
| 2 |
== Migrating from Cowboy 2.5 to 2.6 |
| 3 |
|
| 4 |
Cowboy 2.6 greatly refactored the HTTP/2 code, a large |
| 5 |
part of which was moved to Cowlib and is now used by |
| 6 |
both the Cowboy server and the Gun client. |
| 7 |
|
| 8 |
A large number of tickets were also closed which |
| 9 |
resulted in many bugs fixed and many features and |
| 10 |
options added, although some of them are still |
| 11 |
experimental. |
| 12 |
|
| 13 |
=== Features added |
| 14 |
|
| 15 |
* Add support for the PROXY protocol header. |
| 16 |
It can be enabled via the `proxy_header` option. |
| 17 |
The proxy information can then be found under |
| 18 |
the `proxy_info` key in the Req object. |
| 19 |
|
| 20 |
* Allow using sendfile tuples in `cowboy_req:stream_body/3` |
| 21 |
and in the data command in stream handlers. The only |
| 22 |
caveat is that when using `cowboy_compress_h` the |
| 23 |
sendfile tuples may have to be converted to in-memory |
| 24 |
data in order to compress them. This is the case for |
| 25 |
gzip compression. |
| 26 |
|
| 27 |
* The stream handlers `cowboy_stream_h` and |
| 28 |
`cowboy_compress_h` are now documented. |
| 29 |
|
| 30 |
* Add the `chunked` option to allow disabling chunked |
| 31 |
transfer-encoding for HTTP/1.1 connections. |
| 32 |
|
| 33 |
* Add the `http10_keepalive` option to allow disabling |
| 34 |
keep-alive for HTTP/1.0 connections. |
| 35 |
|
| 36 |
* Add the `idle_timeout` option for HTTP/2. |
| 37 |
|
| 38 |
* Add the `sendfile` option to both HTTP/1.1 and HTTP/2. |
| 39 |
It allows disabling the sendfile syscall entirely for |
| 40 |
all connections. It is recommended to disable sendfile |
| 41 |
when using VirtualBox shared folders. |
| 42 |
|
| 43 |
* Add the `rate_limited/2` callback to REST handlers. |
| 44 |
|
| 45 |
* Add the `deflate_opts` option to Websocket handlers that |
| 46 |
allows configuring deflate options for the |
| 47 |
permessage-deflate extension. |
| 48 |
|
| 49 |
* Add the `charset` option to `cowboy_static`. |
| 50 |
|
| 51 |
* Add support for the SameSite cookie attribute. |
| 52 |
|
| 53 |
* Update Ranch to 1.7.0 |
| 54 |
|
| 55 |
* Update Cowlib to 2.7.0 |
| 56 |
|
| 57 |
=== Experimental features added |
| 58 |
|
| 59 |
* Add support for range requests (RFC7233) in REST handlers. |
| 60 |
This adds two new callbacks: `ranges_accepted/2` and |
| 61 |
`range_satisfiable/2` along with the user-specified |
| 62 |
`ProvideRangeCallback/2`. |
| 63 |
|
| 64 |
* Add automatic handling of range requests to REST handlers |
| 65 |
that return the callback `auto` from `ranges_accepted/2`. |
| 66 |
Cowboy will call the configured `ProvideCallback` and |
| 67 |
then split the output automatically for the ranged response. |
| 68 |
|
| 69 |
* Enable range requests support in `cowboy_static`. |
| 70 |
|
| 71 |
* Add the `{deflate, boolean()}` Websocket handler |
| 72 |
command to disable permessage-deflate compression |
| 73 |
temporarily. |
| 74 |
|
| 75 |
* Add the `compress_threshold` option which allows |
| 76 |
configuring how much data must be present in a |
| 77 |
response body to compress it. This only applies |
| 78 |
to non-streamed bodies at this time. |
| 79 |
|
| 80 |
* Add the `compress_buffering` option which allows |
| 81 |
controlling whether some buffering may be done |
| 82 |
when streaming a response body. Change the default |
| 83 |
behavior to not buffer to make sure it works by |
| 84 |
default in all scenarios. |
| 85 |
|
| 86 |
* Add the `{set_options, map()}` command to stream |
| 87 |
handlers and Websocket handlers. This can be used |
| 88 |
to update options on a per-request basis. Allow |
| 89 |
overriding the `idle_timeout` option for both |
| 90 |
HTTP/1.1 and Websocket, the `cowboy_compress_h` |
| 91 |
options for HTTP/1.1 and HTTP/2 and the `chunked` |
| 92 |
option for HTTP/1.1. |
| 93 |
|
| 94 |
=== Bugs fixed |
| 95 |
|
| 96 |
* Do not send a content-length automatically with |
| 97 |
304 responses. This status code allows a content-length |
| 98 |
that corresponds to what would have been sent for a 200 |
| 99 |
response, but is never followed by a body. |
| 100 |
|
| 101 |
* HTTP/2 streams are now terminated once the body |
| 102 |
has been sent fully, instead of immediately once |
| 103 |
the stop command is returned (by default when the |
| 104 |
request process exits). Metrics will therefore |
| 105 |
more accurately represent when a stream ended. |
| 106 |
|
| 107 |
* Terminate connection processes gracefully when the |
| 108 |
parent process exists or when sys:terminate/2,3 |
| 109 |
is called. |
| 110 |
|
| 111 |
* Automatically ignore the boundary parameter of multipart |
| 112 |
media types when using REST handlers. This is a special |
| 113 |
parameter that may change with all requests and cannot |
| 114 |
be predicted. |
| 115 |
|
| 116 |
* Fix parsing of the accept header when it contains charset |
| 117 |
parameters. They are case insensitive and will now be |
| 118 |
lowercased, like for accept-charset and content-type. |
| 119 |
|
| 120 |
* Handle the charset parameter using `charsets_provided` |
| 121 |
when it is present in the accept header when using |
| 122 |
REST handlers. |
| 123 |
|
| 124 |
* Don't select charsets when the q-value is 0 in REST |
| 125 |
handlers. |
| 126 |
|
| 127 |
* Handle accept-charset headers that include a wildcard |
| 128 |
in REST handlers. |
| 129 |
|
| 130 |
* Only send a charset header when the content-type |
| 131 |
negotiated is of type text in REST handlers. |
| 132 |
|
| 133 |
* Remove the default charset iso-8859-1 from REST |
| 134 |
handlers when no other is provided. This has been |
| 135 |
removed from the HTTP specifications for a long time. |
| 136 |
|
| 137 |
* Many cases where a content-type header was sent |
| 138 |
unnecessarily in the REST handlers response have |
| 139 |
been fixed. |
| 140 |
|
| 141 |
* Handle error_response commands in `cowboy_metrics_h`. |
| 142 |
|
| 143 |
* A number of types and function specifications were |
| 144 |
fixed or improved. Dialyzer is now run against both |
| 145 |
the code and tests to help uncover issues. |
| 146 |
|
| 147 |
* An undefined `cowboy_router` behavior has been |
| 148 |
documented. |