Improved handling of output Message conversion

remove the check for 'accept' header
added test

Resolves #465
This commit is contained in:
Oleg Zhurakousky
2020-03-18 17:01:55 +01:00
parent b28c7c5cfc
commit 919b9902e9
2 changed files with 31 additions and 11 deletions

View File

@@ -735,16 +735,14 @@ public class BeanFactoryAwareFunctionRegistry
Message outputMessage = null;
if (value instanceof Message) {
MessageHeaders headers = ((Message) value).getHeaders();
if (!headers.containsKey("accept")) {
Map<String, Object> headersMap = (Map<String, Object>) ReflectionUtils
.getField(this.headersField, headers);
headersMap.put("accept", acceptedContentType);
// Set the contentType header to the value of accept for "legacy" reasons. But, do not set the
// contentType header to the value of accept if it is a wildcard type, as this doesn't make sense.
// This also applies to the else branch below.
if (acceptedContentType.isConcrete()) {
headersMap.put(MessageHeaders.CONTENT_TYPE, acceptedContentType);
}
Map<String, Object> headersMap = (Map<String, Object>) ReflectionUtils
.getField(this.headersField, headers);
headersMap.put("accept", acceptedContentType);
// Set the contentType header to the value of accept for "legacy" reasons. But, do not set the
// contentType header to the value of accept if it is a wildcard type, as this doesn't make sense.
// This also applies to the else branch below.
if (acceptedContentType.isConcrete()) {
headersMap.put(MessageHeaders.CONTENT_TYPE, acceptedContentType);
}
}
else {