I had the following problem when using RestTemplate. The FormHttpMessageConverter always adds the charset like this application/x-www-form-urlencoded; charset=UTF-8. But, the service I was consuming was malfunctioning if I give the charset like this. It was working with just application/x-www-form-urlencoded without the charset parameter. This is an external service, so I do not have control over it.
How I solved it
I subclassed MediaType, HttpHeaders and HttpEntity, so that the getMediaType method in FormHttpMessageConverter do not try to create a new MediaType with parameters.
What I am proposing
I think there should be a property in the FormHttpMessageConverter includeCharset. We do the charset validation as usual, but before writing the ContentType, we check the flag to exclude the parameter.
I am happy to give a PR if this sounds okay.
I had the following problem when using
RestTemplate. TheFormHttpMessageConverteralways adds the charset like thisapplication/x-www-form-urlencoded; charset=UTF-8. But, the service I was consuming was malfunctioning if I give the charset like this. It was working with justapplication/x-www-form-urlencodedwithout the charset parameter. This is an external service, so I do not have control over it.How I solved it
I subclassed
MediaType,HttpHeadersandHttpEntity, so that thegetMediaTypemethod inFormHttpMessageConverterdo not try to create a newMediaTypewith parameters.What I am proposing
I think there should be a property in the
FormHttpMessageConverterincludeCharset. We do the charset validation as usual, but before writing theContentType, we check the flag to exclude the parameter.I am happy to give a PR if this sounds okay.