Skip to content

Spring HttpInputMessage encoding

Is there any way to get the content encoding from the [HttpInputMessage][1] into a HttpMessageConverter? I browsed the documentation but I cannot find any relevant info.


I’m not sure I understand exactly what you want. If by encoding you mean the Content-Encoding or Content-Type header, then all you have to do is

HttpInputMessage inputMessage = ...;
HttpHeaders headers = inputMessage.getHeaders();
MediaType contentType = headers.getContentType();
String contentEncoding = headers.getFirst("content-encoding"); // it's case insensitive