We're using Spring MVC (3.0.5) for an API we are building. However, we have discovered that the application does not always return a content-length in the response header. Why I haven't figured out as yet. We can not manually set the content-length in the controller (request.setContentLength(x)) because we only use a subset of the data we get with the controller in our Freemarker view. So basically what we need is to calculate and set the content-length after a view has been resolved/compiled and just before it is actually sent to client.
Are there any common ("good praxis") ways to do this? Or even "ugly" ways?