Search code examples
javaservletswildflyundertowwildfly-10

Undertow always add charset to Content-Type header even if it is not a text MIME type


If I try to set the content type to "image/jpg" in a servlet

response.setContentType("image/jpg")

I get

Content-Type: image/jpg;charset=ISO-8859-1

The default servlet works well instead.

How can I get rid of charset for non text mime types?


Solution

  • The problem was that I used resp.getWriter() instead of resp.getOutputStream() to serve images.