Try defaulContentType for application/octet-stream

AbstractHttpMessageConverter now tries to call getDefaultContentType
with the actual value to be converted to see if that will result in
a more concrete mediat type than application/octet-stream.

Issue: SPR-12894
This commit is contained in:
Rossen Stoyanchev
2015-04-13 14:31:25 -04:00
parent b0848db17c
commit 8ff7cc73bc
2 changed files with 32 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -174,6 +174,10 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) {
contentTypeToUse = getDefaultContentType(t);
}
else if (MediaType.APPLICATION_OCTET_STREAM.equals(contentType)) {
MediaType type = getDefaultContentType(t);
contentTypeToUse = (type != null ? type : contentTypeToUse);
}
if (contentTypeToUse != null) {
headers.setContentType(contentTypeToUse);
}