On 24/10/17 07:36, Lazar Kirchev wrote: > Hello, > > Change http://svn.apache.org/viewvc?view=revision&revision=1801052 tries, > in case no charset is specified for the response, to determine a default > one based on the content language if such is present. For en and fr > languages the ISO-8859-1 charset is used as default.
There is slightly more to it than that. If the application sets the "Content-Language" header then Tomcat extracts the Locale from that header and calls setLocale(). This behaviour is not required by the specification but is one of a number of cases where Tomcat tries to map the explicit setting of HTTP headers to Servlet API calls. "Content-Type" and "Content-Length" are the others. The Servlet specification requires that a call to setLocale() also sets the character encoding if one has not already been set via setCharacterEncoding() or setContentType(). > However, this is done for all content types, not only for text media types. > Is this intentional? Yes. The Servlet specification requirement that a call to setLocale() also sets the character encoding if one has not already been set is not dependent on content type. > For example, for some media types (particularly > application/json) this could lead to incorrect representation of characters. It is always better to explicitly set the content type and character set. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org