From 399b6a16b4a571e293437dcc8f85808f83b32ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 2 Nov 2018 12:36:51 +0100 Subject: Better handle content negotiation when accept contains charsets Thanks to Philip Witty for help figuring this out. --- doc/src/manual/cowboy_rest.asciidoc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'doc/src/manual') diff --git a/doc/src/manual/cowboy_rest.asciidoc b/doc/src/manual/cowboy_rest.asciidoc index 1b33bb8..19f4820 100644 --- a/doc/src/manual/cowboy_rest.asciidoc +++ b/doc/src/manual/cowboy_rest.asciidoc @@ -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] -- cgit v1.2.3