title: Spring - POST with binary file - Character decoding failed
body: <p>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: </p>
  
  <pre><code>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.
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>server.tomcat.uri-encoding=UTF-8 #I've also tried UTF-16
  </code></pre>
  
  <p>Thanks for your time.</p>
  
  <p>EDIT (ANSWER):
  You can fix this using an apache proxy with the following configuration:</p>
  
  <pre><code>&lt;Location /endpoint/&gt;
      ProxyPass https://127.0.0.1:443/endpoint/
      RequestHeader unset Content-Type
      RequestHeader set Content-Type "application/octet-stream"
  &lt;/Location&gt;
  </code></pre>
  
  <p>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 <code>RequestHeader unset content-type</code> should be added as well.</p>