Sync MockHttpServletResponse implementations
See gh-33019
This commit is contained in:
@@ -24,6 +24,7 @@ import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -72,6 +73,8 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
|
||||
private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
|
||||
|
||||
private static final MediaType APPLICATION_PLUS_JSON = new MediaType("application", "*+json");
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// ServletResponse properties
|
||||
@@ -348,6 +351,10 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
if (mediaType.getCharset() != null) {
|
||||
setExplicitCharacterEncoding(mediaType.getCharset().name());
|
||||
}
|
||||
else if (mediaType.isCompatibleWith(MediaType.APPLICATION_JSON) ||
|
||||
mediaType.isCompatibleWith(APPLICATION_PLUS_JSON)) {
|
||||
this.characterEncoding = StandardCharsets.UTF_8.name();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Try to get charset value anyway
|
||||
|
||||
Reference in New Issue
Block a user