From cbe2cbcc8829f810113e605554d78245a6de9c72 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 27 Jun 2016 09:34:19 -0400 Subject: [PATCH] CodecHttpMessageConverter supports a default charset --- .../http/converter/reactive/CodecHttpMessageConverter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-web-reactive/src/main/java/org/springframework/http/converter/reactive/CodecHttpMessageConverter.java b/spring-web-reactive/src/main/java/org/springframework/http/converter/reactive/CodecHttpMessageConverter.java index 02a9cf7c71..f61648784e 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/converter/reactive/CodecHttpMessageConverter.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/converter/reactive/CodecHttpMessageConverter.java @@ -144,6 +144,12 @@ public class CodecHttpMessageConverter implements HttpMessageConverter { contentTypeToUse = (mediaType != null ? mediaType : contentTypeToUse); } 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); } }