3.3 Hypertext transfer protocol (HTTP)
In this section, I shall look at one example of an application of the TCP/IP protocol suite – sending hypertext pages over the world wide web (WWW or simply the web). However, first I shall very briefly summarise the main features of the web that are relevant to this discussion. There are many sources of information about the web on the web itself for those who want to know more.
In very basic terms, the web is an application of the Internet for accessing resources wherever they are located. Each resource on the web is found through a name called a uniform resource locator (URL). A URL consists first of the name of the scheme for communicating with the resource at the application layer (e.g. FTP, HTTP, MAILTO) followed by a scheme-specific part. The only scheme we shall look at here is HTTP, and the syntax for HTTP URLs takes the form of:
http:// <host> : <port> / <path> ? <search-part>
where the names in angled brackets indicate that values are inserted in actual URLs. The ‘host’ is the domain name as given in the domain name system of the Internet. The ‘port’ is optional and is described in the next section, but it can be thought of as a way of identifying the different applications that may be running in an application layer. The ‘path’ in a URL identifies the name of the resource in the host's filing system. The ‘search-part’ is optional and is used when the resource is a search engine. If no ‘port’ value is given, then a default value is used.
Identify the component parts of the following URL:
The name of the host is ‘www.altavista.digital.com’, the name of the path is ‘cgi-bin/query’ and the search-part is ‘q=multi-service+network’. No port value is specified, so a default value is used.
When the resource on the web is a hypertext page with links to other pages, retrieving one page of information may trigger several subsequent requests to obtain resources.
In many situations, users access the web through a proxy server, which separates an internal network from the Internet and thereby can offer some degree of protection to the users. A proxy server can also provide temporary local storage (a cache store) of resources obtained from the web. Storing a resource locally can avoid repeating a recent request for the same resource.
Figure 15 shows the application layer view of the communication between peer entities. In this simple example the only function of the proxy server that we are interested in is that of repeating the messages it receives.
HTTP (hypertext transfer protocol) takes the form of commands from a client, typically a browser computer program, and responses from a server. A command (called a method in HTTP terminology) can occupy several lines. The first line has the name of the command, the identity of the resource, and the scheme version number. Subsequent lines may contain parameters, which modify the command, and any data to be transferred to the server. Examples of parameters are the name of the host and a date giving the last time a resource was modified. A response from a server takes the form of a status line, additional information about the type of response, and the resource itself.
Commands and responses are defined in RFC 2616. Some example commands are listed in Table 3 and example responses in Table 4.
Table 3: Example HTTP commands
|Connect||Establishes a tunnel1 through a proxy server|
|Delete||Requests the removal of a resource|
|Get||Requests the retrieval of a resource|
|Head||Requests the retrieval of information about a resource rather than the resource itself|
|Options||Requests information about the capabilities of a server or the requirements of a resource|
|Post||Requests that a resource accepts some information|
|Put||Requests that a resource is stored at the given location|
|Trace||Requests that a server takes part in some test|
1A tunnel is created by encapsulation. A received message is encapsulated in another message so that the received message is transferred transparently through a node or network.
Table 4: Example HTTP responses
Figure 16 shows an example of commands and responses between an HTTP client and server via a proxy server.
HTTP protocol data units are transferred by requesting a connection-oriented service from the transport layer, for example by calling on the TCP protocol to transfer messages between the client and server. In the first version of HTTP, individual connections were set up for each resource and this could entail establishing several consecutive connections for hypertext pages that included links to other resources. The current version of HTTP has improved efficiency by allowing a host to maintain a connection for more than one transfer if appropriate. Efficiency is further improved by allowing a host to submit several requests without waiting for an acknowledgement.