Suppose a browser makes a request
asking for the server to keep the connection alive
(connection: keep-alive).
And this request requires the invocation of a servlet.
Inside my servlet should I care to choose the best
way to send data (chunked or indicating
the lenght of the body ) ??
if the server does that for me , why , inside my servlet ,
I'm able to modyfy headers like:
content-length
and transfer encoding ?
thanks
If you know the body length up front, you should set Content-Length header before writing body.
Otherwise do nothing; the servlet container should be able to automatically add Transfer-Encoding, and chunk-ify your body. That is subject to client/request version and Connection header.