Debian Codegraph @

doc/src/guide/migrating_from_2.10.asciidoc

raw
1 [appendix]
2 == Migrating from Cowboy 2.10 to 2.11
3
4 Cowboy 2.11 contains a variety of new features and bug
5 fixes. Nearly all previously experimental features are
6 now marked as stable, including Websocket over HTTP/2.
7 Included is a fix for an HTTP/2 protocol CVE.
8
9 Cowboy 2.11 requires Erlang/OTP 24.0 or greater.
10
11 Cowboy is now using GitHub Actions for CI. The main reason
12 for the move is to reduce costs by no longer having to
13 self-host CI runners. The downside is that GitHub runners
14 are less reliable and timing dependent tests are now more
15 likely to fail.
16
17 === Features added
18
19 * A new HTTP/2 option `max_cancel_stream_rate` has been added
20 to control the rate of stream cancellation the server will
21 accept. By default Cowboy will accept 500 cancelled streams
22 every 10 seconds.
23
24 * A new stream handler `cowboy_decompress_h` has been added.
25 It allows automatically decompressing incoming gzipped
26 request bodies. It includes options to protect against
27 zip bombs.
28
29 * Websocket over HTTP/2 is no longer considered experimental.
30 Note that the `enable_connect_protocol` option must be set
31 to `true` in order to use Websocket over HTTP/2 for the
32 time being.
33
34 * Automatic mode for reading request bodies has been
35 documented. In automatic mode, Cowboy waits indefinitely
36 for data and sends a `request_body` message when data
37 comes in. It mirrors `{active, once}` socket modes.
38 This is ideal for loop handlers and is also used
39 internally for HTTP/2 Websocket.
40
41 * Ranged requests support is no longer considered
42 experimental. It was added in 2.6 to both `cowboy_static`
43 and `cowboy_rest`. Ranged responses can be produced
44 either automatically (for the `bytes` unit) or manually.
45 REST flowcharts have been updated with the new callbacks
46 and steps related to handling ranged requests.
47
48 * A new HTTP/1.1 and HTTP/2 option `reset_idle_timeout_on_send`
49 has been added. When enabled, the `idle_timeout` will be
50 reset every time Cowboy sends data to the socket.
51
52 * Loop handlers may now return a timeout value in the place
53 of `hibernate`. Timeouts behave the same as in `gen_server`.
54
55 * The `generate_etag` callback of REST handlers now accepts
56 `undefined` as a return value to allow conditionally
57 generating etags.
58
59 * The `cowboy_compress_h` options `compress_threshold` and
60 `compress_buffering` are no longer considered experimental.
61 They were de facto stable since 2.6 as they already were
62 documented.
63
64 * Functions `cowboy:get_env/2,3` have been added.
65
66 * Better error messages have been added when trying to send
67 a 204 or 304 response with a body; when attempting to
68 send two responses to a single request; when trying to
69 push a response after the final response; when trying
70 to send a `set-cookie` header without using
71 `cowboy_req:set_resp_cookie/3,4`.
72
73 === Features removed
74
75 * Cowboy will no longer include the NPN extension when
76 starting a TLS listener. This extension has long been
77 deprecated and replaced with the ALPN extension. Cowboy
78 will continue using the ALPN extension for protocol
79 negotiation.
80
81 === Bugs fixed
82
83 * A fix was made to address the HTTP/2 CVE CVE-2023-44487
84 via the new HTTP/2 option `max_cancel_stream_rate`.
85
86 * HTTP/1.1 requests that contain both a content-length and
87 a transfer-encoding header will now be rejected to avoid
88 security risks. Previous behavior was to ignore the
89 content-length header as recommended by the HTTP RFC.
90
91 * HTTP/1.1 connections would sometimes use the wrong timeout
92 value to determine whether the connection should be closed.
93 This resulted in connections staying up longer than
94 intended. This should no longer be the case.
95
96 * Cowboy now reacts to socket errors immediately for HTTP/1.1
97 and HTTP/2 when possible. Cowboy will notice when connections
98 have been closed properly earlier than before. This also
99 means that the socket option `send_timeout_close` will work
100 as expected.
101
102 * Shutting down HTTP/1.1 pipelined requests could lead to
103 the current request being terminated before the response
104 has been sent. This has been addressed.
105
106 * When using HTTP/1.1 an invalid Connection header will now
107 be rejected with a 400 status code instead of crashing.
108
109 * The documentation now recommends increasing the HTTP/2
110 option `max_frame_size_received`. Cowboy currently uses
111 the protocol default but will increase its default in a
112 future release. Until then users are recommended to set
113 the option to ensure larger requests are accepted and
114 processed with acceptable performance.
115
116 * Cowboy could sometimes send HTTP/2 WINDOW_UPDATE frames
117 twice in a row. Now they should be consolidated.
118
119 * Cowboy would sometimes send HTTP/2 WINDOW_UPDATE frames
120 for streams that have stopped internally. This should
121 no longer be the case.
122
123 * The `cowboy_compress_h` stream handler will no longer
124 attempt to compress responses that have an `etag` header
125 to avoid caching issues.
126
127 * The `cowboy_compress_h` will now always add `accept-encoding`
128 to the `vary` header as it indicates that responses may
129 be compressed.
130
131 * Cowboy will now remove the `trap_exit` process flag when
132 HTTP/1.1 connections upgrade to Websocket.
133
134 * Exit gracefully instead of crashing when the socket gets
135 closed when reading the PROXY header.
136
137 * Missing `cowboy_stream` manual pages have been added.
138
139 * A number of fixes were made to documentation and examples.