Support setCharacterEncoding(null)
in MockHttpServletResponse
#30341
Labels
in: test
Issues in the test module
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Some servlet containers (at least Undertow and Tomcat) allow clearing a previously set character encoding by calling
response.setCharacterEncoding(null)
. This is useful whenCharacterEncodingFilter
is used, but some handlers need to deliver binary data without thecharset
clause in theContent-Type
response header.Code doing that cannot currently be tested with MockMvc, because
MockHttpServletResponse.setCharacterEncoding(null)
throws anIllegalArgumentException
.The Javadoc of the Servlet API in JakartaEE has been updated a while ago to support
null
there: jakartaee/servlet@22c8f34The JakartaEE guys were quite unanimous about the subject: jakartaee/servlet#377
MockHttpServletResponse.setCharacterEncoding(null)
should clear any character encoding previously set on the response.The text was updated successfully, but these errors were encountered: