| 1. | The Hypertext Transfer Protocol (HTTP) is a central protocol in supporting the operations of the World Wide Web (WWW). |
| 2. | It is an application-level protocol that can be used in distributed hypertext information systems. |
| 3. | It is a generic stateless protocol that can be used to transfer any type of data. |
| 4. | HTTP can support other Internet applications including the File Transfer Protocol (FTP) and the Simple Mail Transfer Protocol (SMTP). |
| 5. | Three versions of the HTTP protocol were developed: |
| a) | HTTP/0.9, | |
| b) | HTTP/1.0 and | |
| c) | The latest and currently widely used version is HTTP/1.1. |
| 6. | The specification of HTTP/1.1 is defined in Internet RFC 2616 which can be found at http://www.faqs.org/rfcs/rfc2616.html. |
| 1. | The HTTP protocol is a request reply protocol. |
| 2. | A client program (a web browser such as Internet Explorer) and a server program (Web Server such as Apache) communicate by exchanging HTTP messages. |
| 3. | HTTP defines the structure of these messages and how the client and server exchange such messages. |
| 4. | When a user requests a web page (e.g. by clicking on an HTML hyperlink viewed by a web browser), the browser sends HTTP request messages for the objects in the page, to the web server. |
| 5. | The server receives the requests and then replies with HTTP reply messages containing the objects. |
| 6. | Most browsers and web servers currently implement HTTP/1.1 which is backward compatible with older versions. |
| 1. | HTTP connections are based on TCP as the underlying transport protocol. |
| 2. | Socket interfaces (including ports) are used to link the client and server processes with the TCP connection. |
| 3. | HTTP can use both non-persistent and persistent connections. |
| 4. | The default is the use of persistent connections in HTTP/1.1, earlier versions uses non-persistent connections. |
| 5. | To illustrate the difference between non-persistent and persistent connection, consider an example where a user is trying to request a web page containing seven web objects: an HTML file and six JPEG images and that all objects reside on the same server. The URL for the base HTML file is http://www.someportal.com/index.html. |
| a) | When using a non-persistent connection, the user request for this page is achieved as follows: |
![]() |
The HTTP client process (browser) initiates a TCP connection to the server http://www.somePortal.com on port number 80 (the default port number for HTTP). | ||
![]() |
The HTTP client request is sent to the server via a socket associated with the TCP connection. The request message includes the path name /index.html. | ||
![]() |
The HTTP server receives the request message via its socket associated with the connection, retrieves the object /index.html from its storage, encapsulates it in a HTTP response message and sends the response to the client. | ||
![]() |
The HTTP server tells TCP to close the TCP connection. |
![]() |
The HTTP client receives the response message and the TCP connection terminates. | ||
![]() |
The client extracts the HTML file and finds references to 6 JPEG objects. | ||
![]() |
Steps 1-5 are repeated for each of the 6 JPEG objects. |
| b) | When using a persistent connection, the server leaves the TCP connection open after sending a response. | |
| c) | Subsequent requests and responses between the client and server can be sent over the same connection. | |
| d) | Thus, the base HTML file and all the 6 JPEG objects can be sent over a single persistent connection. | |
| e) | In addition, multiple web pages residing on the same server can be sent to the same client over one persistent TCP connection. | |
| f) | Typically, the HTTP closes the connection after time-out period expires without the connection being used. |
| 6. | There are two types of persistent connections; without pipelining and with pipelining. |
| 7. | When pipelining is enabled, the HTTP client can make subsequent requests without waiting for replies to be received for previous request. |
| 8. | Thus, a client can make a request as soon as it encounters a reference. |
| 9. | Pipelining reduces the time during which the persistent connection is idle (not in use) and can reduce the delays required for requests to fulfilled. |
| 1. | Saving resources (processing and memory) when fewer connections are handled by clients, servers, caches, proxies, etc. |
| 2. | Reducing network congestion as fewer control messages are required. |
| 3. | Latency is reduced as the overhead of opening connections is eliminated after the first request. |
| 1. | The HTTP specification includes the definition of the HTTP message format. |
| 2. | There are two types of HTTP messages, request messages and reply messages. |
| 3. | Both types of messages consist of a start line, zero or more header fields, an empty line and possibly a message body. |
| 1. | An illustration of the request message is shown in Figure 9.2. |
| 2. | The first line of an HTTP request message is the request line and the subsequent lines are called header lines. |
| 3. | The request line has three fields: the method field, the URL field and the HTTP version. |
| 4. | Part of the request message start line is a method that is required to be applied to the resource being requested. |
| 5. | HTTP defines a set of fixed methods, one of which should be part of any HTTP request message. Such methods include: |
| a) | OPTIONS: allows the client to query the requirements associated with a resource or the capabilities of the server, without requesting a resource action. | |
| b) | GET: a method to request the retrieval of all information identified by the URI included in the request message. Result of this method is cacheable by web proxies. | |
| c) | HEAD: identical to GET, except that the server does not return a message body in the response. Usually used for testing and validating hypertext links. | |
| d) | POST: used in a variety of ways including posting messages to newsgroups and mailing lists, providing data in the request such as data fields of a form or extending database through an append operation. The result of the POST method is not cacheable. | |
| e) | PUT: a method that requests that the enclosed entity to be stored under the supplied URI. | |
| f) | DELETE: requests the server to delete the resource specified by the supplied URI. |

| 1. | An example of a HTTP request message is shown in Listing 9.1. |
| a) | It can be seen that the message is written in ordinary ASCI text, making it human-readable. | |
| b) | The header line Host specifies the host on which the requested objected specified in the request line resides. | |
| c) | The second header line “Connection: close”, is used by the browser to inform the server that it does not need a persistent connection. | |
| d) | The browser type is specified in the next line. | |
| e) | Accept-language, specifies the language in which the user prefers to accept the requested object, which is English in this example. |

| 1. | An illustration of the HTTP reply message is shown in Figure 9.3. |
| 2. | The first line is a status line containing the HTTP version the server is using, a status code and a corresponding status message. |
| 3. | Some common status codes and their corresponding status messages are listed below: |
| 4. | 200 OK: Request succeeded and the information is returned in response. |
| 5. | 301 Moved Permanently: Requested object has been permanently moved, new URL is specified in the Location header field of the response message. The client browser will automatically request the resource addressed by the new URL. |
| 6. | 400 Bad Request: This is a generic error code indicating that the request could not be understood by the server. |
| 7. | 404 Not Found: The requested document does not exist on this server. |
| 8. | 505 HTTP Version Not Supported: The requested HTTP protocol version is not supported by the server. |
| 9. | The status line is followed by zero or more header lines and then a message body. |
| 10. | An example of a HTTP reply message is illustrated in Listing 9.2. |
| a) | The status line specifies the HTTP protocol version 1.1 followed by status code 200 indicating that the reply message contains the data requested. | |
| b) | The Connection header line (with value close) informs the client that the TCP connection is going to be closed after sending the message. | |
| c) | The Date header line indicates the time and date when the HTTP response message was created and sent by the server. | |
| d) | The Server header line indicates that the message was generated by an Apache Web Server. | |
| e) | The Content-Length indicates the number of bytes in the web object being sent. | |
| f) | The Content-Type indicates that the object in the entity body is HTML text. | |
| g) | Files of the web objects transferred are included in the message body. |

