2016-12-22 15:19:38 +01:00
|
|
|
= cowboy_http2(3)
|
|
|
|
|
|
|
|
== Name
|
|
|
|
|
|
|
|
cowboy_http2 - HTTP/2
|
|
|
|
|
|
|
|
== Description
|
|
|
|
|
|
|
|
The module `cowboy_http2` implements HTTP/2
|
|
|
|
as a Ranch protocol.
|
|
|
|
|
2016-12-22 18:13:25 +01:00
|
|
|
== Options
|
2016-12-22 15:19:38 +01:00
|
|
|
|
2017-05-05 13:48:25 +02:00
|
|
|
// @todo Might be worth moving cowboy_clear/tls/stream_h options
|
|
|
|
// to their respective manual, when they are added.
|
|
|
|
|
2016-12-22 15:19:38 +01:00
|
|
|
[source,erlang]
|
|
|
|
----
|
|
|
|
opts() :: #{
|
2018-04-26 22:08:05 +02:00
|
|
|
connection_type => worker | supervisor,
|
2019-09-02 14:48:28 +02:00
|
|
|
connection_window_margin_size => 0..16#7fffffff,
|
|
|
|
connection_window_update_threshold => 0..16#7fffffff,
|
2018-04-26 22:08:05 +02:00
|
|
|
enable_connect_protocol => boolean(),
|
2018-11-16 16:30:57 +01:00
|
|
|
idle_timeout => timeout(),
|
2018-04-26 22:08:05 +02:00
|
|
|
inactivity_timeout => timeout(),
|
|
|
|
initial_connection_window_size => 65535..16#7fffffff,
|
|
|
|
initial_stream_window_size => 0..16#7fffffff,
|
|
|
|
max_concurrent_streams => non_neg_integer() | infinity,
|
2019-09-02 14:48:28 +02:00
|
|
|
max_connection_window_size => 0..16#7fffffff,
|
2018-04-26 22:08:05 +02:00
|
|
|
max_decode_table_size => non_neg_integer(),
|
|
|
|
max_encode_table_size => non_neg_integer(),
|
2018-04-27 17:58:11 +02:00
|
|
|
max_frame_size_received => 16384..16777215,
|
|
|
|
max_frame_size_sent => 16384..16777215 | infinity,
|
2019-09-13 14:20:04 +02:00
|
|
|
max_stream_buffer_size => non_neg_integer(),
|
2019-09-02 14:48:28 +02:00
|
|
|
max_stream_window_size => 0..16#7fffffff,
|
2018-04-26 22:08:05 +02:00
|
|
|
preface_timeout => timeout(),
|
2018-11-14 12:32:31 +01:00
|
|
|
proxy_header => boolean(),
|
2018-11-03 18:55:40 +01:00
|
|
|
sendfile => boolean(),
|
2018-04-28 10:59:56 +02:00
|
|
|
settings_timeout => timeout(),
|
2019-09-02 14:48:28 +02:00
|
|
|
stream_handlers => [module()],
|
|
|
|
stream_window_margin_size => 0..16#7fffffff,
|
|
|
|
stream_window_update_threshold => 0..16#7fffffff
|
2016-12-22 15:19:38 +01:00
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
Configuration for the HTTP/2 protocol.
|
|
|
|
|
|
|
|
This configuration is passed to Cowboy when starting listeners
|
2017-06-07 15:15:54 +02:00
|
|
|
using `cowboy:start_clear/3` or `cowboy:start_tls/3` functions.
|
2016-12-22 15:19:38 +01:00
|
|
|
|
|
|
|
It can be updated without restarting listeners using the
|
|
|
|
Ranch functions `ranch:get_protocol_options/1` and
|
|
|
|
`ranch:set_protocol_options/2`.
|
|
|
|
|
2016-12-22 18:13:25 +01:00
|
|
|
The default value is given next to the option name:
|
2016-12-22 15:19:38 +01:00
|
|
|
|
2017-05-05 13:48:25 +02:00
|
|
|
connection_type (supervisor)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
|
|
|
Whether the connection process also acts as a supervisor.
|
2017-05-05 13:48:25 +02:00
|
|
|
|
2019-09-02 14:48:28 +02:00
|
|
|
connection_window_margin_size (65535)::
|
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
Extra amount in bytes to be added to the window size when
|
2019-09-02 14:48:28 +02:00
|
|
|
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
|
2019-09-06 11:50:58 +02:00
|
|
|
becomes lower than this threshold, in bytes. This is to
|
|
|
|
avoid sending too many `WINDOW_UPDATE` frames.
|
2019-09-02 14:48:28 +02:00
|
|
|
|
2018-04-04 17:23:37 +02:00
|
|
|
enable_connect_protocol (false)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
|
|
|
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.
|
2018-04-04 17:23:37 +02:00
|
|
|
|
2018-11-16 16:30:57 +01:00
|
|
|
idle_timeout (60000)::
|
|
|
|
|
|
|
|
Time in ms with no data received before Cowboy closes the connection.
|
|
|
|
|
2017-05-05 13:48:25 +02:00
|
|
|
inactivity_timeout (300000)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
|
|
|
Time in ms with nothing received at all before Cowboy closes the connection.
|
2017-05-05 13:48:25 +02:00
|
|
|
|
2018-04-26 22:08:05 +02:00
|
|
|
initial_connection_window_size (65535)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
Initial window size in bytes for the connection. This is the total amount
|
2018-05-02 11:08:27 +02:00
|
|
|
of data (from request bodies for example) that may be buffered
|
|
|
|
by the connection across all streams before the user code
|
|
|
|
explicitly requests it.
|
2018-04-26 22:08:05 +02:00
|
|
|
+
|
2018-05-02 11:08:27 +02:00
|
|
|
Note that this value cannot be lower than the default.
|
2018-04-26 22:08:05 +02:00
|
|
|
|
|
|
|
initial_stream_window_size (65535)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
Initial window size in bytes for new streams. This is the total amount
|
2018-05-02 11:08:27 +02:00
|
|
|
of data (from request bodies for example) that may be buffered
|
|
|
|
by a single stream before the user code explicitly requests it.
|
2018-04-26 22:08:05 +02:00
|
|
|
|
2018-04-25 21:32:58 +02:00
|
|
|
max_concurrent_streams (infinity)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
|
|
|
Maximum number of concurrent streams allowed on the connection.
|
2018-04-25 21:32:58 +02:00
|
|
|
|
2019-09-02 14:48:28 +02:00
|
|
|
max_connection_window_size (16#7fffffff)::
|
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
Maximum connection window size in bytes. This is used as an upper bound
|
2019-09-02 14:48:28 +02:00
|
|
|
when calculating the window size, either when reading the request
|
|
|
|
body or receiving said body.
|
|
|
|
|
2018-04-25 16:55:52 +02:00
|
|
|
max_decode_table_size (4096)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
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.
|
2018-04-25 16:55:52 +02:00
|
|
|
|
|
|
|
max_encode_table_size (4096)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
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.
|
2018-04-25 16:55:52 +02:00
|
|
|
|
2018-04-27 17:58:11 +02:00
|
|
|
max_frame_size_received (16384)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
Maximum size in bytes of the frames received by the server. This value is
|
2018-05-02 11:08:27 +02:00
|
|
|
advertised to the remote endpoint which can then decide to use
|
|
|
|
any value lower or equal for its frame sizes.
|
2018-04-27 17:58:11 +02:00
|
|
|
|
|
|
|
max_frame_size_sent (infinity)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
Maximum size in bytes of the frames sent by the server. This option allows
|
2018-05-02 11:08:27 +02:00
|
|
|
setting an upper limit to the frame sizes instead of blindly
|
|
|
|
following the client's advertised maximum.
|
2018-04-27 17:58:11 +02:00
|
|
|
+
|
2018-05-02 11:08:27 +02:00
|
|
|
Note that actual frame sizes may be lower than the limit when
|
|
|
|
there is not enough space left in the flow control window.
|
2018-04-27 17:58:11 +02:00
|
|
|
|
2019-09-13 14:20:04 +02:00
|
|
|
max_stream_buffer_size (8000000)::
|
|
|
|
|
|
|
|
Maximum stream buffer size in bytes. This is a soft limit used
|
|
|
|
to apply backpressure to handlers that send data faster than
|
|
|
|
the HTTP/2 connection allows.
|
|
|
|
|
2019-09-02 14:48:28 +02:00
|
|
|
max_stream_window_size (16#7fffffff)::
|
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
Maximum stream window size in bytes. This is used as an upper bound
|
2019-09-02 14:48:28 +02:00
|
|
|
when calculating the window size, either when reading the request
|
|
|
|
body or receiving said body.
|
|
|
|
|
2016-12-22 15:19:38 +01:00
|
|
|
preface_timeout (5000)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
|
|
|
Time in ms Cowboy is willing to wait for the connection preface.
|
2016-12-22 15:19:38 +01:00
|
|
|
|
2018-11-14 12:32:31 +01:00
|
|
|
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.
|
|
|
|
|
2018-11-03 18:55:40 +01:00
|
|
|
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.
|
|
|
|
|
2018-04-28 10:59:56 +02:00
|
|
|
settings_timeout (5000)::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
|
|
|
Time in ms Cowboy is willing to wait for a SETTINGS ack.
|
2018-04-28 10:59:56 +02:00
|
|
|
|
2017-05-05 13:48:25 +02:00
|
|
|
stream_handlers ([cowboy_stream_h])::
|
2018-05-02 11:08:27 +02:00
|
|
|
|
|
|
|
Ordered list of stream handlers that will handle all stream events.
|
2017-05-05 13:48:25 +02:00
|
|
|
|
2019-09-02 14:48:28 +02:00
|
|
|
stream_window_margin_size (65535)::
|
|
|
|
|
2019-09-06 11:50:58 +02:00
|
|
|
Extra amount in bytes to be added to the window size when
|
2019-09-02 14:48:28 +02:00
|
|
|
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
|
2019-09-06 11:50:58 +02:00
|
|
|
becomes lower than this threshold, in bytes. This is to avoid sending
|
2019-09-02 14:48:28 +02:00
|
|
|
too many `WINDOW_UPDATE` frames.
|
|
|
|
|
2016-12-22 15:19:38 +01:00
|
|
|
== Changelog
|
|
|
|
|
2019-09-02 14:48:28 +02:00
|
|
|
* *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
|
2019-09-13 14:20:04 +02:00
|
|
|
behavior on sending WINDOW_UPDATE frames, and
|
|
|
|
`max_stream_buffer_size` to apply backpressure
|
|
|
|
when sending data too fast.
|
2018-11-14 17:12:06 +01:00
|
|
|
* *2.6*: The `proxy_header` and `sendfile` options were added.
|
2018-04-26 22:08:05 +02:00
|
|
|
* *2.4*: Add the options `initial_connection_window_size`,
|
|
|
|
`initial_stream_window_size`, `max_concurrent_streams`,
|
2018-04-27 17:58:11 +02:00
|
|
|
`max_decode_table_size`, `max_encode_table_size`,
|
2018-04-28 10:59:56 +02:00
|
|
|
`max_frame_size_received`, `max_frame_size_sent`
|
|
|
|
and `settings_timeout` to configure HTTP/2 SETTINGS
|
|
|
|
and related behavior.
|
2018-04-25 16:55:52 +02:00
|
|
|
* *2.4*: Add the experimental option `enable_connect_protocol`.
|
2016-12-22 15:19:38 +01:00
|
|
|
* *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)]
|