-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Konstantin,

On 3/26/13 11:08 AM, Konstantin Kolinko wrote:
> 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 = ?

Duh. I'm running both Tomcat 6.0.36 and Tomcat 7.0.35.

> 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

Mostly POST requests. I'll take a look at the commit to see what was
changed and see if it might be relevant.

> 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.

Hmm... I might be flushing the buffer explicitly. That's probably a
stupid idea because Tomcat should ultimately flush everything for me.
I'll check on that.

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

All servlets in these cases. I'll follow-up with better answers to the
above.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRUgHzAAoJEBzwKT+lPKRYjp8QAJmDS7eebC0S8tM+yG0C+PTy
tyczL2vaxu1bwLlt5LDwFwQ9q6S7NtPvGQiRIGqg3VDWz9H2q3UVDRR3v/zhyxdE
ZPutdXWRPPmU26ZyEF4W3ttyxGmtm+y4zpAkUfLW/h0Zl9gVDV6TqwYX9GsylEyV
/RrAN4AHKh2uBJc6SnV61wU5a+7LrBTy9Tlxi0om7UGf8sGoXTGDtmEpYYUfJDQu
+cUN3OTaOStdBXR+gLQ17NSlY+/nTZVoMMIfrJHTVBjAWpAQQwAXCZMaCfmdbaYS
EkNk8cehmnHyhYhy6JckbpC1qaugDwVERaOl86LcuSsKFzPAdFaoHS+XF6Qp2GDk
gtiw6wpTiM6DF6f2BP6ZXJLcddmtZMhtygGsKLXyxmR9hguOKVioVPIi5GDnifZR
0PtTjmY1dis/Xcfe/WKIKJER8jRtiBpzLHOLpomFh95hL1y7dnfRUYv9EzlrtV1k
TdQurstjKsd7P7XWUsSpyyjXmluCWZQoCJbzVwEdMMmar6kfaAGqgCj4FAHV/JTH
wNKRqd461q1hj/dKKJk65KbyKSFP2y4zpF/irtVvH4y0JyNAJWzmxdC8XJHu3EAp
Q9UsvPuZNtICR3twPoFzicJm1wXLV00TCg7XYiXExNZarDnzA6GAtOVMx5Oxmuaq
osWzVzmulIbdy9enhTZR
=AVzf
-----END PGP SIGNATURE-----

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

Reply via email to