
The TCP/IP Guide - Version 3.0 (Contents) ` 1546 _ © 2001-2005 Charles M. Kozierok. All Rights Reserved.
Note: A DNS name resolution step may precede the entire HTTP connection,
since most URLs contain a host name, while HTTP requires that the client know
the server's IP address. This can cause confusion, especially since DNS uses
UDP where HTTP uses TCP.
Once the TCP connection is active, the client sends its first request message. As we will
see in the next section, the request specifies what version of HTTP the client is using. If this
is HTTP/0.9 or HTTP/1.0, the server will automatically work in the transitory connection
model, and will only send one reply and then close the link. If it is HTTP/1.1, the assumption
is that a persistent connection is desired. An HTTP/1.1 client can override this by including
the special Connection: close header in its initial request, which tells the server it does not
want to keep the session active after the request it is sending has been fulfilled.
Persistent Connection Use and Management
Assuming that a persistent connection is being used, the client may begin pipelining subse-
quent requests after sending its first request, while waiting for a response from the server to
the initial query. As the server starts to respond to requests, the client processes them and
takes action such as displaying the data retrieved to the user. The data received from the
server may also prompt the client to request more files on the same connection, as in the
case of an HTML document that contains references to images.
The server will generally buffer a certain number of pipelined requests from the client. In the
case where the client sends too many requests too quickly, the server may “throttle back”
the client using the flow control mechanism built into TCP. In theory, the server could also
just decided to terminate the connection with the client, but it is better for it to use TCP’s
existing features. Closing the connection will cause the client to initiate a new connection,
potentially exacerbating any overloading problem.
Connection Termination
The flow of requests and responses continues for as long as the client has requests. The
connection can be gracefully terminated by the client by including the Connection: close
header in the last request it needs to send to the server. All requests are filled in order, so
the server will satisfy all outstanding requests and then close the session.
Since HTTP/1.1 supports pipelining of requests, there is usually no need for a client to
establish more than one simultaneous connection to the same server. Clients occasionally
do this anyway to allow them to get information from a server more quickly. This is
considered by many to be “anti-social”, because it can lead to a busy server's resources
being monopolized by one client to the exclusion of others that want to access it.
Under special circumstances, either the client or the server may unexpectedly close an
active persistent connection. For example, if the client detects that too much time has
elapsed since the server last replied, it may conclude that the server has crashed and