I'm running a spring-boot app that seems to be having trouble with a particular request. The request is a POST containing binary data however, when the JavaServlet(Or tomcat?) receives it, it doesn't know how to decode it so it produces the following error:
org.apache.tomcat.util.http.Parameters : Character decoding failed. Parameter [0 *H÷
0 UUS1#0!U
S§¥ø§'ôZúöf¿(å_Ý«"õéñ¤åyl¢Ýg0izt¡÷~ÅüvDt¿Äû¨Ë åt@òÔÊdJRBq%2¶ úFsX] with value [] has been ignored. Note that the name and value quoted here may be corrupted due to the failed decoding. Use debug level logging to see the original, non-corrupted values.
I'm aware of the following config which seems to have some effect on it, but I don't know what to set the value to for a post that contains a binary:
server.tomcat.uri-encoding=UTF-8 #I've also tried UTF-16
Thanks for your time.
EDIT (ANSWER): You can fix this using an apache proxy with the following configuration:
<Location /endpoint/>
ProxyPass https://127.0.0.1:443/endpoint/
RequestHeader unset Content-Type
RequestHeader set Content-Type "application/octet-stream"
</Location>
Unsetting the Content-Type is optional, the set should override I believe. However, I'm not 100% the field is case-insensitive. It's possible RequestHeader unset content-type
should be added as well.
application/x-www-form-urleconded
isn't an appropriate content type for binary data. Tomcat thinks you've POSTed a form to it and is trying to parse the names and values of the fields from the binary data. You should use a content type that's appropriate for binary data. application/octet-stream
is one option.