简体   繁体   中英

managing keep-alive http connection inside servlet

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM