-
Notifications
You must be signed in to change notification settings - Fork 804
Closed

Description
Story
A user writes a MessageConverter
implementation that they wish to use via SpringEncoder
. This message converter produces binary payloads.
Attempts to do so, however, have the request treated as though it were in the UTF8 charset, regardless of the actual content. This causes the request to be encoded and interpreted incorrectly. This holds true even if the custom converter specifies a charset
parameter in the request content type(s) that it supports!
Steps to Reproduce
- Create a new
MessageConverter
that is not derived fromByteArrayMessageConverter
orProtobufHttpMessageConverter
. The converter should produce a binary request (non-text contents) with a suitable request content type, such asapplication/octet-stream
. - Configure a
SpringEncoder
with this message converter. - Attempt to send a request with a body consisting of content converted by this message converter.
- Observe that the request is treated as being in UTF8 encoding.
Cause
The logic in question begins on line 128 of SpringEncoder
.
Proposed Solution
Two potential solutions (not mutually exclusive) would be:
- Honor any request content types set by the
MessageConverter
. If the converter sets a content type with acharset
parameter, use that as the encoding for theRequest.Body
instance. - Extend
SpringEncoder
such that a message converter may be configured with a charset override (i.e. "whenever calling this converter, assume a specific charset for the body encoding". - Failing the above, at least limit the default behavior to cases where it would make sense. Treating a request with a content type of
application/octet-stream
as being in UTF8 is not a safe assumption. (Same goes for most if not all of the non-text
types + subtypes.)
Please let me know if anything is unclear or if you need more information.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request