>-----Original Message----- >From: Christopher Schultz [mailto:ch...@christopherschultz.net] >Subject: Adding Content-Length response header > >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA256 > >All, > >Here's the situation I have: I've got a response that I'm fairly sure fits >into the >response's buffer size, and I'd like to send a Content-Length header in that >case. I could probably put a wrapper around the response's >ServletOutputStream that counts bytes and then looks for "done" conditions >(OutputStream.close, etc.), then adds a Content-Length header if the >response hasn't yet been committed.
What about using a ByteArrayOutputStream? It has a size method and you could use that in the response.setContentLength() and write out the ByteArrayOutputStream to your ServletOutputStream? Maybe? > >Thanks, >- -chris