cowboy_http2.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. enable_connect_protocol => boolean(),
  15. env => cowboy_middleware:env(),
  16. inactivity_timeout => timeout(),
  17. initial_connection_window_size => 65535..16#7fffffff,
  18. initial_stream_window_size => 0..16#7fffffff,
  19. max_concurrent_streams => non_neg_integer() | infinity,
  20. max_decode_table_size => non_neg_integer(),
  21. max_encode_table_size => non_neg_integer(),
  22. max_frame_size_received => 16384..16777215,
  23. max_frame_size_sent => 16384..16777215 | infinity,
  24. middlewares => [module()],
  25. preface_timeout => timeout(),
  26. shutdown_timeout => timeout(),
  27. stream_handlers => [module()]
  28. }
  29. ----
  30. Configuration for the HTTP/2 protocol.
  31. This configuration is passed to Cowboy when starting listeners
  32. using `cowboy:start_clear/3` or `cowboy:start_tls/3` functions.
  33. It can be updated without restarting listeners using the
  34. Ranch functions `ranch:get_protocol_options/1` and
  35. `ranch:set_protocol_options/2`.
  36. The default value is given next to the option name:
  37. connection_type (supervisor)::
  38. Whether the connection process also acts as a supervisor.
  39. enable_connect_protocol (false)::
  40. Whether to enable the extended CONNECT method to allow
  41. protocols like Websocket to be used over an HTTP/2 stream.
  42. This option is experimental and disabled by default.
  43. env (#{})::
  44. Middleware environment.
  45. inactivity_timeout (300000)::
  46. Time in ms with nothing received at all before Cowboy closes the connection.
  47. initial_connection_window_size (65535)::
  48. Initial window size for the connection. This is the total amount
  49. of data (from request bodies for example) that may be buffered
  50. by the connection across all streams before the user code
  51. explicitly requests it.
  52. +
  53. Note that this value cannot be lower than the default.
  54. initial_stream_window_size (65535)::
  55. Initial window size for new streams. This is the total amount
  56. of data (from request bodies for example) that may be buffered
  57. by a single stream before the user code explicitly requests it.
  58. max_concurrent_streams (infinity)::
  59. Maximum number of concurrent streams allowed on the connection.
  60. max_decode_table_size (4096)::
  61. Maximum header table size used by the decoder. This is the value advertised
  62. to the client. The client can then choose a header table size equal or lower
  63. to the advertised value.
  64. max_encode_table_size (4096)::
  65. Maximum header table size used by the encoder. The server will compare this
  66. value to what the client advertises and choose the smallest one as the
  67. encoder's header table size.
  68. max_frame_size_received (16384)::
  69. Maximum size of the frames received by the server. This value is
  70. advertised to the remote endpoint which can then decide to use
  71. any value lower or equal for its frame sizes.
  72. max_frame_size_sent (infinity)::
  73. Maximum size of the frames sent by the server. This option allows
  74. setting an upper limit to the frame sizes instead of blindly
  75. following the client's advertised maximum.
  76. +
  77. Note that actual frame sizes may be lower than the limit when
  78. there is not enough space left in the flow control window.
  79. middlewares ([cowboy_router, cowboy_handler])::
  80. Middlewares to run for every request.
  81. preface_timeout (5000)::
  82. Time in ms Cowboy is willing to wait for the connection preface.
  83. shutdown_timeout (5000)::
  84. Time in ms Cowboy will wait for child processes to shut down before killing them.
  85. stream_handlers ([cowboy_stream_h])::
  86. Ordered list of stream handlers that will handle all stream events.
  87. == Changelog
  88. * *2.4*: Add the options `initial_connection_window_size`,
  89. `initial_stream_window_size`, `max_concurrent_streams`,
  90. `max_decode_table_size`, `max_encode_table_size`,
  91. `max_frame_size_received` and `max_frame_size_sent`
  92. to configure HTTP/2 SETTINGS.
  93. * *2.4*: Add the experimental option `enable_connect_protocol`.
  94. * *2.0*: Protocol introduced.
  95. == See also
  96. link:man:cowboy(7)[cowboy(7)],
  97. link:man:cowboy_http(3)[cowboy_http(3)],
  98. link:man:cowboy_websocket(3)[cowboy_websocket(3)]