Previous Topic

Next Topic

Book Contents

Book Index

Persistent Connection

Opening and closing TCP sockets consumes a considerable amount of CPU time, bandwidth and memory. Both version of HTTP - 1.0 and 1.1 offer mechanisms to reuse TCP/IP connections.

HTTP 1.0 has defined a value for the Connection header, Keep-Alive, which is sent whenever the client or the server wishes to keep the connection alive. This header is usable only if the Content-Length of the body can be sent, otherwise the connection must be closed in order to mark the end of the response body.

HTTP 1.1 introduces the Transfer-Encoding: chunked header, which provides a mechanism to make a connection persistent, while transferring dynamic data.

When an HTTP 1.0 request comes, HTTP Bundle tries to implement the keep-alive mechanism, but if a servlet generates the response body, then the connection can be kept only if the servlet has set the Content-Length header.

Responses to HTTP 1.1 requests generally contain the Transfer-Encoding: chunked, this header is not sent only if the servlet defines the content length.