2013/3/26 Christopher Schultz <ch...@christopherschultz.net>:
>
> Like most folks on the list, I have quite a few dynamic resources
> being served through Tomcat. For nearly all of them, the
> Content-Length response header is /not/ included in the response
> because either content length isn't known when the response is
> committed, and therefore the Content-Length header simply cannot be
> sent or the response is not being buffered in the application, and so
> the application isn't counting bytes and doesn't know the content
> length even if it could be reported.
>
> I'm wondering if Tomcat can do anything about that.
>
> 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.
>
> I wonder if Tomcat could do something like that more easily -- since
> the buffer is being managed by Tomcat already, and Tomcat knows when
> the response will be committed/completed.
>
> So,
>
> A: Is this something that Tomcat can do already? I don't see any
> configuration options that sound like they would do this kind of thing.
>
> B: Is this something appropriate for a container to do in general?
>
> C: If I were to write a Filter to accomplish this manually, are there
> any potential dangers if a traditional non-synchronous
> request/response is being processed?

1. Your Tomcat version = ?

2. Are you interested in GET/POST requests, or HEAD requests?

HEAD requests were fixed by this commit, from 5 days ago
 http://svn.apache.org/r1459087

3. Tomcat is already able to provide Content-Length header when all
response fits into a buffer.

But, if an explicit flush() is called, Tomcat has to start sending
data (usually using chunked encoding) and thus content length  is not
known at the time when response headers are being sent.

What generates your response? A servlet, a filter, or a JSP?

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to