I have just started to fail after this change 9b30d46.
My content type candidate is like this one:
if (CollectionUtils.isEmpty(acceptTypes)) {
acceptTypes = Collections.singletonList(MediaType.ALL);
}
So, MediaType.ALL is really compatible with MediaType.APPLICATION_JSON, but it is wrong value for the Content-Type header:
java.lang.IllegalArgumentException: Content-Type cannot contain wildcard type '*'
at org.springframework.util.Assert.isTrue(Assert.java:118)
at org.springframework.http.HttpHeaders.setContentType(HttpHeaders.java:949)
at org.springframework.http.converter.StringHttpMessageConverter.addDefaultHeaders(StringHttpMessageConverter.java:109)
at org.springframework.http.converter.StringHttpMessageConverter.addDefaultHeaders(StringHttpMessageConverter.java:44)
at org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:211)
Any clues what to use instead of MediaType.ALL when no Accept header in the request?
Or maybe this fix should be improved to skip MediaType.ALL as it is done in the super class:
if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) {
contentTypeToUse = getDefaultContentType(t);
}
Note that AbstractMessageConverterMethodProcessor is not used in Spring Integration.
There logic in the HttpRequestHandlingMessagingGateway is like this: https://github.com/spring-projects/spring-integration/blob/master/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGateway.java#L171
So, instead of falling back to the MediaType.APPLICATION_OCTET_STREAM we try to rely on the Content-Type populated by the converted which fits to the payload we would like to return into the response.
Originally based on discussion.
I have just started to fail after this change 9b30d46.
My content type candidate is like this one:
So,
MediaType.ALLis really compatible withMediaType.APPLICATION_JSON, but it is wrong value for theContent-Typeheader:Any clues what to use instead of
MediaType.ALLwhen noAcceptheader in the request?Or maybe this fix should be improved to skip
MediaType.ALLas it is done in the super class:Note that
AbstractMessageConverterMethodProcessoris not used in Spring Integration.There logic in the
HttpRequestHandlingMessagingGatewayis like this: https://github.com/spring-projects/spring-integration/blob/master/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGateway.java#L171So, instead of falling back to the
MediaType.APPLICATION_OCTET_STREAMwe try to rely on the Content-Type populated by the converted which fits to thepayloadwe would like to return into the response.Originally based on discussion.