migrating_from_2.5.asciidoc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. [appendix]
  2. == Migrating from Cowboy 2.5 to 2.6
  3. Cowboy 2.6 greatly refactored the HTTP/2 code, a large
  4. part of which was moved to Cowlib and is now used by
  5. both the Cowboy server and the Gun client.
  6. A large number of tickets were also closed which
  7. resulted in many bugs fixed and many features and
  8. options added, although some of them are still
  9. experimental.
  10. === Features added
  11. * Add support for the PROXY protocol header.
  12. It can be enabled via the `proxy_header` option.
  13. The proxy information can then be found under
  14. the `proxy_info` key in the Req object.
  15. * Allow using sendfile tuples in `cowboy_req:stream_body/3`
  16. and in the data command in stream handlers. The only
  17. caveat is that when using `cowboy_compress_h` the
  18. sendfile tuples may have to be converted to in-memory
  19. data in order to compress them. This is the case for
  20. gzip compression.
  21. * Add an `http10_keepalive` option to allow disabling
  22. keep-alive for HTTP/1.0 connections.
  23. * Add an `idle_timeout` option for HTTP/2.
  24. * Add a `sendfile` option to both HTTP/1.1 and HTTP/2.
  25. It allows disabling the sendfile syscall entirely for
  26. all connections. It is recommended to disable sendfile
  27. when using VirtualBox shared folders.
  28. * Add the `rate_limited/2` callback to REST handlers.
  29. * Add a `deflate_opts` option to Websocket handlers that
  30. allows configuring deflate options for the
  31. permessage-deflate extension.
  32. * Add a `charset` option to `cowboy_static`.
  33. * Add support for the SameSite cookie attribute.
  34. * Update Ranch to 1.7.0
  35. * Update Cowlib to 2.7.0
  36. === Experimental features added
  37. * Add support for range requests (RFC7233) in REST handlers.
  38. This adds two new callbacks: `ranges_accepted/2` and
  39. `range_satisfiable/2` along with the user-specified
  40. `ProvideRangeCallback/2`.
  41. * Add automatic handling of range requests to REST handlers
  42. that return the callback `auto` from `ranges_accepted/2`.
  43. Cowboy will call the configured `ProvideCallback` and
  44. then split the ouput automatically for the ranged response.
  45. * Enable range requests support in `cowboy_static`.
  46. * Add the `{deflate, boolean()}` Websocket handler
  47. command to disable permessage-deflate compression
  48. temporarily.
  49. * Add the `compress_threshold` option which allows
  50. configuring how much data must be present in a
  51. response body to compress it. This only applies
  52. to non-streamed bodies at this time.
  53. * Add the `compress_buffering` option which allows
  54. controlling whether some buffering may be done
  55. when streaming a response body. Change the default
  56. behavior to not buffer to make sure it works by
  57. default in all scenarios.
  58. * Add the `{set_options, map()}` command to stream
  59. handlers and Websocket handlers. This can be used
  60. to update options on a per-request basis. Allow
  61. overriding the `idle_timeout` option for both
  62. HTTP/1.1 and Websocket, and the `cowboy_compress_h`
  63. options for HTTP/1.1 and HTTP/2.
  64. === Bugs fixed
  65. * Do not send a content-length automatically with
  66. 304 responses. This status code allows a content-length
  67. that corresponds to what would have been sent for a 200
  68. response, but is never followed by a body.
  69. * HTTP/2 streams are now terminated once the body
  70. has been sent fully, instead of immediately once
  71. the stop command is returned (by default when the
  72. request process exits). Metrics will therefore
  73. more accurately represent when a stream ended.
  74. * Terminate connection processes gracefully when the
  75. parent process exists or when sys:terminate/2,3
  76. is called.
  77. * Automatically ignore the boundary parameter of multipart
  78. media types when using REST handlers. This is a special
  79. parameter that may change with all requests and cannot
  80. be predicted.
  81. * Fix parsing of the accept header when it contains charset
  82. parameters. They are case insensitive and will now be
  83. lowercased, like for accept-charset and content-type.
  84. * Handle the charset parameter using `charsets_provided`
  85. when it is present in the accept header when using
  86. REST handlers.
  87. * Don't select charsets when the q-value is 0 in REST
  88. handlers.
  89. * Handle accept-charset headers that include a wildcard
  90. in REST handlers.
  91. * Only send a charset header when the content-type
  92. negotiated is of type text in REST handlers.
  93. * Remove the default charset iso-8859-1 from REST
  94. handlers when no other is provided. This has been
  95. removed from the HTTP specifications for a long time.
  96. * Many cases where a content-type header was sent
  97. unnecessarily in the REST handlers response have
  98. been fixed.
  99. * Handle error_response commands in `cowboy_metrics_h`.
  100. * A number of types and function specifications were
  101. fixed or improved. Dialyzer is now run against both
  102. the code and tests to help uncover issues.
  103. * An undefined `cowboy_router` behavior has been
  104. documented.