cowboy_http2.asciidoc 7.1 KB

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