CodecHttpMessageConverter supports a default charset

master
Rossen Stoyanchev 8 years ago
parent 67175005e3
commit cbe2cbcc88
  1. 6
      spring-web-reactive/src/main/java/org/springframework/http/converter/reactive/CodecHttpMessageConverter.java

@ -144,6 +144,12 @@ public class CodecHttpMessageConverter<T> implements HttpMessageConverter<T> {
contentTypeToUse = (mediaType != null ? mediaType : contentTypeToUse); contentTypeToUse = (mediaType != null ? mediaType : contentTypeToUse);
} }
if (contentTypeToUse != null) { if (contentTypeToUse != null) {
if (contentTypeToUse.getCharset() == null) {
MediaType mediaType = getDefaultContentType(type);
if (mediaType != null && mediaType.getCharset() != null) {
contentTypeToUse = new MediaType(contentTypeToUse, mediaType.getCharset());
}
}
headers.setContentType(contentTypeToUse); headers.setContentType(contentTypeToUse);
} }
} }

Loading…
Cancel
Save