you need to add the headers _before_ committing the response.
The problem is, I want to add _trailing_ headers at the end of the HTTP response after the chunked body as the HTTP specification tells. I know, that I have to add a header to tell about the presence of a trailing header, what is not the issue. The issue is to put the actual trailing header at the end of the response. As far as I see it, there are only headers to be added to the response header, but not at the end. Or do I miss an option or functionality here?
On the other side: One of the main functions of a trailing header is to add a checksum for instance, which can only be calculated at the end of the stream when the stream is already sent to the client. The functionality is killed, if I need to stream once for the checksum and a second time after adding the header to send everything to the client.
You have to write your own ChunkedOutputFilter to do that and you need your own application to process the trailers of each chunk that will be sent by the filter.