Hi,
I already posted the question to StackOverflow:
http://stackoverflow.com/q/13204865/269891
Basically output buffering behavior differs based on whether I use a
vanilla servlet and a Jersey resource.
(I'm using Jetty 8.1.7.v20120910 as the server, Jersey 1.14 Spring
Servlet)
(Vanilla servlet case)
Jetty by default provide a header buffer of 6kB and an output buffer of
32kB, as long as your response
fits into these buffers and you don't use extra flushes, your output is
send with a Content-Length header (i.e. not chunked)
If you go above 32kB your output will be set as chunked in 32kB chunks.
However, if you write a small amount to the output stream and flush
your response will always be sent chunked with chunks equal to the size
you flush.
(Jersey servlet case)
If I use the Jersey servlet and a simple Jersey resource just
outputting a string, no matter whether I flush or not, the output is
always chunked, and if I don't use extra flushes the chunks are limited
to 16kB (instead of Jetty's deafult 32kB).
I can understand the output sent always chunked since Jersey probably
flushes the output after writing, and in that case Jetty sends the
output as chunked (this is also correct for the vanilla servlet case)
But what I don't understand is the 16kB limit. Why is it different than
the 32kB provided by Jetty?
Can anyone shed some light on this behavior?
(While I navigated the sources I found that Jersey sets a default
buffer size of 8kB, if that were 16kB I would say that was causing it)
Thanks,
Kaan.
PS: Sorry if this turns out Jetty related instead of Jersey, but it
seems to me that it is related with Jersey :)