cowboy_http2.asciidoc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. = cowboy_http2(3)
  2. == Name
  3. cowboy_http2 - HTTP/2
  4. == Description
  5. The module `cowboy_http2` implements HTTP/2
  6. as a Ranch protocol.
  7. == Options
  8. // @todo Might be worth moving cowboy_clear/tls/stream_h options
  9. // to their respective manual, when they are added.
  10. [source,erlang]
  11. ----
  12. opts() :: #{
  13. connection_type => worker | supervisor,
  14. connection_window_margin_size => 0..16#7fffffff,
  15. connection_window_update_threshold => 0..16#7fffffff,
  16. enable_connect_protocol => boolean(),
  17. idle_timeout => timeout(),
  18. inactivity_timeout => timeout(),
  19. initial_connection_window_size => 65535..16#7fffffff,
  20. initial_stream_window_size => 0..16#7fffffff,
  21. max_concurrent_streams => non_neg_integer() | infinity,
  22. max_connection_window_size => 0..16#7fffffff,
  23. max_decode_table_size => non_neg_integer(),
  24. max_encode_table_size => non_neg_integer(),
  25. max_frame_size_received => 16384..16777215,
  26. max_frame_size_sent => 16384..16777215 | infinity,
  27. max_stream_window_size => 0..16#7fffffff,
  28. preface_timeout => timeout(),
  29. proxy_header => boolean(),
  30. sendfile => boolean(),
  31. settings_timeout => timeout(),
  32. stream_handlers => [module()],
  33. stream_window_margin_size => 0..16#7fffffff,
  34. stream_window_update_threshold => 0..16#7fffffff
  35. }
  36. ----
  37. Configuration for the HTTP/2 protocol.
  38. This configuration is passed to Cowboy when starting listeners
  39. using `cowboy:start_clear/3` or `cowboy:start_tls/3` functions.
  40. It can be updated without restarting listeners using the
  41. Ranch functions `ranch:get_protocol_options/1` and
  42. `ranch:set_protocol_options/2`.
  43. The default value is given next to the option name:
  44. connection_type (supervisor)::
  45. Whether the connection process also acts as a supervisor.
  46. connection_window_margin_size (65535)::
  47. Extra amount in bytes to be added to the window size when
  48. updating the connection window. This is used to
  49. ensure that there is always some space available in
  50. the window.
  51. connection_window_update_threshold (163840)::
  52. The connection window will only get updated when its size
  53. becomes lower than this threshold, in bytes. This is to
  54. avoid sending too many `WINDOW_UPDATE` frames.
  55. enable_connect_protocol (false)::
  56. Whether to enable the extended CONNECT method to allow
  57. protocols like Websocket to be used over an HTTP/2 stream.
  58. This option is experimental and disabled by default.
  59. idle_timeout (60000)::
  60. Time in ms with no data received before Cowboy closes the connection.
  61. inactivity_timeout (300000)::
  62. Time in ms with nothing received at all before Cowboy closes the connection.
  63. initial_connection_window_size (65535)::
  64. Initial window size in bytes for the connection. This is the total amount
  65. of data (from request bodies for example) that may be buffered
  66. by the connection across all streams before the user code
  67. explicitly requests it.
  68. +
  69. Note that this value cannot be lower than the default.
  70. initial_stream_window_size (65535)::
  71. Initial window size in bytes for new streams. This is the total amount
  72. of data (from request bodies for example) that may be buffered
  73. by a single stream before the user code explicitly requests it.
  74. max_concurrent_streams (infinity)::
  75. Maximum number of concurrent streams allowed on the connection.
  76. max_connection_window_size (16#7fffffff)::
  77. Maximum connection window size in bytes. This is used as an upper bound
  78. when calculating the window size, either when reading the request
  79. body or receiving said body.
  80. max_decode_table_size (4096)::
  81. Maximum header table size in bytes used by the decoder. This is the value
  82. advertised to the client. The client can then choose a header table size
  83. equal or lower to the advertised value.
  84. max_encode_table_size (4096)::
  85. Maximum header table size in bytes used by the encoder. The server will
  86. compare this value to what the client advertises and choose the smallest
  87. one as the encoder's header table size.
  88. max_frame_size_received (16384)::
  89. Maximum size in bytes of the frames received by the server. This value is
  90. advertised to the remote endpoint which can then decide to use
  91. any value lower or equal for its frame sizes.
  92. max_frame_size_sent (infinity)::
  93. Maximum size in bytes of the frames sent by the server. This option allows
  94. setting an upper limit to the frame sizes instead of blindly
  95. following the client's advertised maximum.
  96. +
  97. Note that actual frame sizes may be lower than the limit when
  98. there is not enough space left in the flow control window.
  99. max_stream_window_size (16#7fffffff)::
  100. Maximum stream window size in bytes. This is used as an upper bound
  101. when calculating the window size, either when reading the request
  102. body or receiving said body.
  103. preface_timeout (5000)::
  104. Time in ms Cowboy is willing to wait for the connection preface.
  105. proxy_header (false)::
  106. Whether incoming connections have a PROXY protocol header. The
  107. proxy information will be passed forward via the `proxy_header`
  108. key of the Req object.
  109. sendfile (true)::
  110. Whether the sendfile syscall may be used. It can be useful to disable
  111. it on systems where the syscall has a buggy implementation, for example
  112. under VirtualBox when using shared folders.
  113. settings_timeout (5000)::
  114. Time in ms Cowboy is willing to wait for a SETTINGS ack.
  115. stream_handlers ([cowboy_stream_h])::
  116. Ordered list of stream handlers that will handle all stream events.
  117. stream_window_margin_size (65535)::
  118. Extra amount in bytes to be added to the window size when
  119. updating a stream's window. This is used to
  120. ensure that there is always some space available in
  121. the window.
  122. stream_window_update_threshold (163840)::
  123. A stream's window will only get updated when its size
  124. becomes lower than this threshold, in bytes. This is to avoid sending
  125. too many `WINDOW_UPDATE` frames.
  126. == Changelog
  127. * *2.7*: Add the options `connection_window_margin_size`,
  128. `connection_window_update_threshold`,
  129. `max_connection_window_size`, `max_stream_window_size`,
  130. `stream_window_margin_size` and
  131. `stream_window_update_threshold` to configure
  132. behavior on sending WINDOW_UPDATE frames.
  133. * *2.6*: The `proxy_header` and `sendfile` options were added.
  134. * *2.4*: Add the options `initial_connection_window_size`,
  135. `initial_stream_window_size`, `max_concurrent_streams`,
  136. `max_decode_table_size`, `max_encode_table_size`,
  137. `max_frame_size_received`, `max_frame_size_sent`
  138. and `settings_timeout` to configure HTTP/2 SETTINGS
  139. and related behavior.
  140. * *2.4*: Add the experimental option `enable_connect_protocol`.
  141. * *2.0*: Protocol introduced.
  142. == See also
  143. link:man:cowboy(7)[cowboy(7)],
  144. link:man:cowboy_http(3)[cowboy_http(3)],
  145. link:man:cowboy_websocket(3)[cowboy_websocket(3)]