type is overwritten by FormHttpMessageConverter
I'm using FormHttpMessageConverter in Spring Framework. For sending a file by restTemplate, I added FormHttpMessageConverter in my project.
The problem is the server where takes the file asked string encrypted Content-type of me. I had to send the file with Content-type: multipart/form-data, but they asked "Content-type: multipart/form-data;" and "boundary:XXXX" .
So I tried to make a value for boundary before send the file. However, the boundary value was overwritted when RestTemplate.exchage() The reason was FormHttpMessageConverter. FormHttpMessageConverter caught the request for converting. If Content-type is multipart/form-data, FormHttpMessageConverter overwrites boundary value by this code.
https://github.com/spring-projects/spring-framework/blob/5f4d1a4628513ab34098fa3f92ba03aa20fc4204/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java#L336
I couldn't find the way to avoid this problem, so I copied that code at the link, and made a file "xxxFormHttpMessageConverter" and modified the method "writeMultipart".
Do someone know how to avoid this overwriting?
链接地址: http://www.djcxy.com/p/48720.html