Set string value for originalContentType in message header
- Since the `originalContentType` header is preserved across the wire while the serialization/de-serialization processes take place using the deduced `contentType`, it is convenient to set the `String` value of the `originalContentType` instead of setting the actual `MimeType` object in the header. - Once the `de-serialization` has taken place, the deduced `contentType` is always replaced with the `originalContentType` as the `contentType` in the message header and this preserved contentType can be resolved to its corresponding MimeType using `ContentTypeResolver` anytime. Hence, using the `String` object for `originalContentType` doesn't do any harm. - Fix the issue while setting the deduced contentType based on the `payload` when the `originalContentType` is `application/json` - Currently, the contentType is set to `text/plain` which seems incorrect - Also, add the `application/json` contentType to return `String` object during de-serialization process. This resolves #383 Use `text/plain` contentType when the payload is of type `String` - This is for the intermediate contentType that is used for serialization/de-serialization
This commit is contained in:
committed by
Marius Bogoevici
parent
b184f67ee1
commit
7021d2195d
@@ -50,6 +50,7 @@ import com.esotericsoftware.kryo.Registration;
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author David Turanski
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
public class MessageChannelBinderSupportTests {
|
||||
|
||||
@@ -122,11 +123,11 @@ public class MessageChannelBinderSupportTests {
|
||||
|
||||
assertEquals(MimeTypeUtils.TEXT_PLAIN,
|
||||
contentTypeResolver.resolve(converted.getHeaders()));
|
||||
assertEquals(MimeTypeUtils.APPLICATION_JSON,
|
||||
assertEquals(MimeTypeUtils.APPLICATION_JSON.toString(),
|
||||
converted.getHeaders().get(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE));
|
||||
MessageValues reconstructed = binder.deserializePayloadIfNecessary(converted);
|
||||
assertEquals("{\"foo\":\"foo\"}", reconstructed.getPayload());
|
||||
assertEquals(MimeTypeUtils.APPLICATION_JSON, reconstructed.get(MessageHeaders.CONTENT_TYPE));
|
||||
assertEquals(MimeTypeUtils.APPLICATION_JSON.toString(), reconstructed.get(MessageHeaders.CONTENT_TYPE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user