Fix HTTP responses that caller asked to be JSON

If caller says he accepts application/json we need to be sure that
we send an array. That wasn't quite working and hadn't been tested.
This commit is contained in:
Dave Syer
2017-01-20 17:44:58 +00:00
committed by markfisher
parent 8e3370b717
commit 946f4a3bf3
3 changed files with 15 additions and 3 deletions

View File

@@ -65,7 +65,7 @@ public class FluxHttpMessageConverter implements HttpMessageConverter<Flux<Objec
MediaType mediaType = inputMessage.getHeaders().getContentType();
if (mediaType != null) {
if (mediaType.includes(MediaType.APPLICATION_JSON)) {
if (!MediaType.ALL.equals(mediaType) && mediaType.includes(MediaType.APPLICATION_JSON)) {
return new JsonObjectDecoder().decode(inputMessage.getBody());
}
if (mediaType.includes(EVENT_STREAM)) {

View File

@@ -81,7 +81,7 @@ class ResponseBodyEmitterSubscriber<T> implements Subscriber<T>, Runnable {
else {
responseBodyEmitter.send(",");
}
if (value.getClass()==String.class) {
if (value.getClass()==String.class && !((String)value).contains("\"")) {
object = "\"" + value + "\"";
}
}