I'm using Spring MVC to setup a REST controller that returns a JSON object, using MappingJacksonHttpMessageConverter.
How do I tell the MappingJacksonHttpMessageConverter to also set the "Content-Length" attribute on the response header ? (By default the "Content-Length" is set to -1, as the MappingJacksonHttpMessageConverter does not calculate the JSON object length).
I do not care if the content length calculation will affect the controller's response time (as the MappingJacksonHttpMessageConverter will need to buffer the marshalled JSON object in order to calculate its length).
This question was already asked, however not answered.
use my MappingJsonHttpMessageConverter instead of MappingJacksonHttpMessageConverter the writeInternal where I add ByteArrayOutputStream and Content-length