0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Better handle content negotiation when accept contains charsets

Thanks to Philip Witty for help figuring this out.
This commit is contained in:
Loïc Hoguin 2018-11-02 12:36:51 +01:00
parent d4dff21055
commit 399b6a16b4
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
6 changed files with 231 additions and 19 deletions

View file

@ -272,6 +272,16 @@ Cowboy treats all parameters as case sensitive, except for the
should therefore always provide the charset as a lowercase
binary string.
When a charset is given in the media type parameters in the
accept header, Cowboy will do some additional checks to confirm
that it can use this charset. When the wildcard is used then Cowboy
will immediately call `charsets_provided` to confirm the charset
is acceptable. If the callback is undefined Cowboy assumes any
charset is acceptable. When the wildcard is not used and the charset
given in the accept header matches one of the configured media
types Cowboy will use that charset and skip the `charsets_provided`
step entirely.
Cowboy will add the negotiated `media_type` to the Req object
after this step completes:
@ -284,6 +294,16 @@ req() :: #{
// @todo Case sensitivity of parsed mime content?
Cowboy may also add the negotiated `charset` to the Req object
after this step completes:
[source,erlang]
----
req() :: #{
charset => binary() %% lowercase; case insensitive
}
----
=== delete_completed
[source,erlang]