JSON charset handling in StringHttpMessageConverter

This commit restores the interpretation of JSON as UTF-8 by default that
was removed in #bc205e0 and also ensures a charset is not appended
automatically to "application/json".

Closes gh-24123
This commit is contained in:
Rossen Stoyanchev
2019-12-10 16:37:31 +00:00
parent 70a0c93d69
commit 9b30d46ff4
3 changed files with 40 additions and 2 deletions

View File

@@ -1011,7 +1011,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
request.addHeader("Accept", "application/json, text/javascript, */*");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getHeader("Content-Type")).as("Invalid content-type").isEqualTo("application/json;charset=ISO-8859-1");
assertThat(response.getHeader("Content-Type")).as("Invalid content-type").isEqualTo("application/json");
}
@Test
@@ -1548,7 +1548,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
getServlet().service(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getHeader("Content-Type")).isEqualTo("application/json;charset=ISO-8859-1");
assertThat(response.getHeader("Content-Type")).isEqualTo("application/json");
assertThat(response.getContentAsString()).isEqualTo("homeJson");
}