Currently the Web API does not understand Accept-Charset headers where a preference is stated. A value of:
Accept-Charset: utf-16
works, but a value of:
Accept-Charset: utf-8; q=0.2, utf-16;q=1.8
does not. Also, if an unsupported charset is requested, the server should respond with HTTP 406 Not Acceptable. Instead it returns UTF8.
Comments: The media type is the main thing we negotiate on and for that you can ask the DefaultContentNegotiator to either send a default formatter response or a 406 response. For accept-charset we ask the formatter that was picked based on media type to then pick the best charset encoding but if it can't find one then it uses the default charset encoding. This behavior is fine from an HTTP perspective. Using the media type as the key component in the negotiation algorithm helps provide a bounded algorithm. Henrik
Accept-Charset: utf-16
works, but a value of:
Accept-Charset: utf-8; q=0.2, utf-16;q=1.8
does not. Also, if an unsupported charset is requested, the server should respond with HTTP 406 Not Acceptable. Instead it returns UTF8.
Comments: The media type is the main thing we negotiate on and for that you can ask the DefaultContentNegotiator to either send a default formatter response or a 406 response. For accept-charset we ask the formatter that was picked based on media type to then pick the best charset encoding but if it can't find one then it uses the default charset encoding. This behavior is fine from an HTTP perspective. Using the media type as the key component in the negotiation algorithm helps provide a bounded algorithm. Henrik