| 1 |
[appendix] |
| 2 |
== Migrating from Cowboy 2.1 to 2.2 |
| 3 |
|
| 4 |
Cowboy 2.2 focused on adding features required for writing |
| 5 |
gRPC servers and on completing test suites for the core |
| 6 |
HTTP RFCs, fixing many bugs along the way. |
| 7 |
|
| 8 |
=== Features added |
| 9 |
|
| 10 |
* Add support for sending trailers at the end of response bodies. |
| 11 |
Trailers are additional header fields that may be sent after the |
| 12 |
body to add more information to the response. Their usage is |
| 13 |
required in gRPC servers. They are optional and may be discarded |
| 14 |
in other scenarios (for example if the request goes through an |
| 15 |
HTTP/1.0 proxy, as HTTP/1.0 does not support trailers). |
| 16 |
|
| 17 |
* The `max_skip_body_length` option was added to `cowboy_http`. |
| 18 |
It controls how much of a request body Cowboy is willing to skip |
| 19 |
when the handler did not touch it. If the remaining body size is |
| 20 |
too large Cowboy instead closes the connection. It defaults to 1MB. |
| 21 |
|
| 22 |
* The CONNECT and TRACE methods are now rejected as they are |
| 23 |
currently not implemented and must be handled differently than |
| 24 |
other methods. They will be implemented in a future release. |
| 25 |
|
| 26 |
=== New functions |
| 27 |
|
| 28 |
* The function `stream_trailers/2` has been added. It terminates |
| 29 |
a stream and adds trailer fields at the end of the response. A |
| 30 |
corresponding stream handler command `{trailers, Trailers}` |
| 31 |
has also been added. |
| 32 |
|
| 33 |
=== Bugs fixed |
| 34 |
|
| 35 |
* Test suites for the core HTTP RFCs RFC7230, RFC7231 and RFC7540 |
| 36 |
have been completed. Many of the bugs listed here were fixed as |
| 37 |
a result of this work. |
| 38 |
|
| 39 |
* Many HTTP/2 edge cases when clients are misbehaving have been |
| 40 |
corrected. This includes many cases where the request is malformed |
| 41 |
(for example when a pseudo-header is present twice). |
| 42 |
|
| 43 |
* When the HTTP/2 SETTINGS_INITIAL_WINDOW_SIZE value changes, |
| 44 |
Cowboy now properly updates the flow control windows. |
| 45 |
|
| 46 |
* HTTP/2 could mistakenly log stray messages that actually were |
| 47 |
expected. This is no longer the case. |
| 48 |
|
| 49 |
* We no longer send a GOAWAY frame when the HTTP/2 preface is invalid. |
| 50 |
|
| 51 |
* Some values in the Req object of pushed requests were in the |
| 52 |
wrong type. They are now the expected binary instead of iolist. |
| 53 |
|
| 54 |
* A response body was sometimes sent in response to HEAD requests |
| 55 |
when using HTTP/2. The body is now ignored. |
| 56 |
|
| 57 |
* The `max_headers` option for `cowboy_http` was not always respected |
| 58 |
depending on the contents of the buffer. The limit is now strict. |
| 59 |
|
| 60 |
* When an early error occurred on the HTTP/1.1 request line, the |
| 61 |
partial Req given to stream handlers was missing the `ref` and |
| 62 |
`peer` information. This has been corrected. |
| 63 |
|
| 64 |
* Absolute URIs with a userinfo component, or without an authority |
| 65 |
component, are now properly rejected for HTTP/1.0 and HTTP/1.1. |
| 66 |
|
| 67 |
* Whitespace is no longer allowed in header lines before the colon. |
| 68 |
|
| 69 |
* 408 responses to HTTP/1.1 requests now properly include a |
| 70 |
connection: close header indicating that we are going to |
| 71 |
close the connection. This header will also be sent for |
| 72 |
other early errors resulting in the closing of the connection. |
| 73 |
|
| 74 |
* When both the transfer-encoding and content-length headers are |
| 75 |
sent in an HTTP/1.1 request, the transfer-encoding now takes |
| 76 |
precedence over the content-length header and the latter is |
| 77 |
removed from the Req object. |
| 78 |
|
| 79 |
* A 400 response is now returned when the transfer-encoding |
| 80 |
header is invalid or contains any transfer-coding other |
| 81 |
than chunked. |
| 82 |
|
| 83 |
* Invalid chunk sizes are now rejected immediately. |
| 84 |
|
| 85 |
* Chunk extensions are now limited to 129 characters. They are |
| 86 |
not used in practice and are still ignored by Cowboy. The limit |
| 87 |
is not configurable. |
| 88 |
|
| 89 |
* The final chunk was mistakenly sent in responses to HEAD |
| 90 |
requests. This is now corrected. |
| 91 |
|
| 92 |
* `OPTIONS *` requests were broken in Cowboy 2.0. They are now |
| 93 |
working again. Both the routing and `cowboy_req:uri/1,2` have |
| 94 |
been corrected. |
| 95 |
|
| 96 |
* 204 responses no longer include a content-length header. |
| 97 |
|
| 98 |
* A packet could be lost when switching to Websocket or any |
| 99 |
other protocol via the `switch_protocol` command. This is |
| 100 |
now fixed. |
| 101 |
|
| 102 |
* A 426 response will now be sent when a handler requires |
| 103 |
the client to upgrade to Websocket and the request did not |
| 104 |
include the required headers. |
| 105 |
|
| 106 |
* Both experimental stream handlers `cowboy_metrics_h` and |
| 107 |
`cowboy_tracer_h` received a number of fixes and improvements. |