aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/manual/cowboy_http2.asciidoc
blob: 19271d4fb13f05d1a7d45252a3b2ee44e67c0bb3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
= cowboy_http2(3)

== Name

cowboy_http2 - HTTP/2

== Description

The module `cowboy_http2` implements HTTP/2
as a Ranch protocol.

== Options

// @todo Might be worth moving cowboy_clear/tls/stream_h options
// to their respective manual, when they are added.

[source,erlang]
----
opts() :: #{
    connection_type                => worker | supervisor,
    connection_window_margin_size  => 0..16#7fffffff,
    connection_window_update_threshold => 0..16#7fffffff,
    enable_connect_protocol        => boolean(),
    idle_timeout                   => timeout(),
    inactivity_timeout             => timeout(),
    initial_connection_window_size => 65535..16#7fffffff,
    initial_stream_window_size     => 0..16#7fffffff,
    max_concurrent_streams         => non_neg_integer() | infinity,
    max_connection_window_size     => 0..16#7fffffff,
    max_decode_table_size          => non_neg_integer(),
    max_encode_table_size          => non_neg_integer(),
    max_frame_size_received        => 16384..16777215,
    max_frame_size_sent            => 16384..16777215 | infinity,
    max_stream_window_size         => 0..16#7fffffff,
    preface_timeout                => timeout(),
    proxy_header                   => boolean(),
    sendfile                       => boolean(),
    settings_timeout               => timeout(),
    stream_handlers                => [module()],
    stream_window_margin_size      => 0..16#7fffffff,
    stream_window_update_threshold => 0..16#7fffffff
}
----

Configuration for the HTTP/2 protocol.

This configuration is passed to Cowboy when starting listeners
using `cowboy:start_clear/3` or `cowboy:start_tls/3` functions.

It can be updated without restarting listeners using the
Ranch functions `ranch:get_protocol_options/1` and
`ranch:set_protocol_options/2`.

The default value is given next to the option name:

connection_type (supervisor)::

Whether the connection process also acts as a supervisor.

connection_window_margin_size (65535)::

Extra amount in bytes to be added to the window size when
updating the connection window. This is used to
ensure that there is always some space available in
the window.

connection_window_update_threshold (163840)::

The connection window will only get updated when its size
becomes lower than this threshold, in bytes. This is to
avoid sending too many `WINDOW_UPDATE` frames.

enable_connect_protocol (false)::

Whether to enable the extended CONNECT method to allow
protocols like Websocket to be used over an HTTP/2 stream.
This option is experimental and disabled by default.

idle_timeout (60000)::

Time in ms with no data received before Cowboy closes the connection.

inactivity_timeout (300000)::

Time in ms with nothing received at all before Cowboy closes the connection.

initial_connection_window_size (65535)::

Initial window size in bytes for the connection. This is the total amount
of data (from request bodies for example) that may be buffered
by the connection across all streams before the user code
explicitly requests it.
+
Note that this value cannot be lower than the default.

initial_stream_window_size (65535)::

Initial window size in bytes for new streams. This is the total amount
of data (from request bodies for example) that may be buffered
by a single stream before the user code explicitly requests it.

max_concurrent_streams (infinity)::

Maximum number of concurrent streams allowed on the connection.

max_connection_window_size (16#7fffffff)::

Maximum connection window size in bytes. This is used as an upper bound
when calculating the window size, either when reading the request
body or receiving said body.

max_decode_table_size (4096)::

Maximum header table size in bytes used by the decoder. This is the value
advertised to the client. The client can then choose a header table size
equal or lower to the advertised value.

max_encode_table_size (4096)::

Maximum header table size in bytes used by the encoder. The server will
compare this value to what the client advertises and choose the smallest
one as the encoder's header table size.

max_frame_size_received (16384)::

Maximum size in bytes of the frames received by the server. This value is
advertised to the remote endpoint which can then decide to use
any value lower or equal for its frame sizes.

max_frame_size_sent (infinity)::

Maximum size in bytes of the frames sent by the server. This option allows
setting an upper limit to the frame sizes instead of blindly
following the client's advertised maximum.
+
Note that actual frame sizes may be lower than the limit when
there is not enough space left in the flow control window.

max_stream_window_size (16#7fffffff)::

Maximum stream window size in bytes. This is used as an upper bound
when calculating the window size, either when reading the request
body or receiving said body.

preface_timeout (5000)::

Time in ms Cowboy is willing to wait for the connection preface.

proxy_header (false)::

Whether incoming connections have a PROXY protocol header. The
proxy information will be passed forward via the `proxy_header`
key of the Req object.

sendfile (true)::

Whether the sendfile syscall may be used. It can be useful to disable
it on systems where the syscall has a buggy implementation, for example
under VirtualBox when using shared folders.

settings_timeout (5000)::

Time in ms Cowboy is willing to wait for a SETTINGS ack.

stream_handlers ([cowboy_stream_h])::

Ordered list of stream handlers that will handle all stream events.

stream_window_margin_size (65535)::

Extra amount in bytes to be added to the window size when
updating a stream's window. This is used to
ensure that there is always some space available in
the window.

stream_window_update_threshold (163840)::

A stream's window will only get updated when its size
becomes lower than this threshold, in bytes. This is to avoid sending
too many `WINDOW_UPDATE` frames.

== Changelog

* *2.7*: Add the options `connection_window_margin_size`,
         `connection_window_update_threshold`,
         `max_connection_window_size`, `max_stream_window_size`,
         `stream_window_margin_size` and
         `stream_window_update_threshold` to configure
         behavior on sending WINDOW_UPDATE frames.
* *2.6*: The `proxy_header` and `sendfile` options were added.
* *2.4*: Add the options `initial_connection_window_size`,
         `initial_stream_window_size`, `max_concurrent_streams`,
         `max_decode_table_size`, `max_encode_table_size`,
         `max_frame_size_received`, `max_frame_size_sent`
         and `settings_timeout` to configure HTTP/2 SETTINGS
         and related behavior.
* *2.4*: Add the experimental option `enable_connect_protocol`.
* *2.0*: Protocol introduced.

== See also

link:man:cowboy(7)[cowboy(7)],
link:man:cowboy_http(3)[cowboy_http(3)],
link:man:cowboy_websocket(3)[cowboy_websocket(3)]