next up previous contents index
Next: 2.3 Protocols and Standards Up: 2. HTTP Servers Previous: 2.1 Introduction   Contents   Index

2.2 Tasks of an HTTP Server

In general, an HTTP server waits for requests and answers them corresponding to the Hypertext Transfer Protocol. A client (usually a web browser) requests a resource (usually an HTML(G) or image file). The server examines the request and maps the requested resource to a file or forwards the request to a program which, in turn, produces the requested data. Finally, the server sends the response back to the client.

Figure 2.1: Simple system (structure and behavior) (View PDF)

The left-hand side of figure 2.1 shows a very simple system structure: The user communicates with the browser and the browser sends a request (R) to the HTTP server which, in turn, reads files from a storage (please note that the server has read-only access to the file storage).

This is a simplified view: The browser is a program running on a computer connected to the HTTP Server via a network. The channel between the user and the browser involves screen, mouse and keyboard. Finally, only one connection is visible although a browser can connect to multiple servers.

On the right-hand side, figure 2.1 also depicts what happens in the system: The user enters a URL in the browser or clicks on a hyperlink. The Web Browser extracts the server address from the URL or link and establishes a TCP/IP connection with the server. Using the connection, the browser sends a GET request to the HTTP server. It extracts the resource name to be requested from the URL or the link.

The HTTP Server reads the request and processes it (i.e. translates it to a file name). It sends the resource in its response using the connection and finally closes the connection. The browser examines the received data. An HTML document can contain links to further resources needed to display it properly, like images or java applets. The browser has to request them from the HTTP server, too, as they are not included in the HTML document. After receiving the last resource needed to display the HTML document, the browser successfully renders the page and waits for further activities of the user.

Figure 2.1 shows a very simplified view of the system: It is easy to see that establishing and closing TCP/IP connections for each resource is a waste of time and network bandwidth. HTTP/1.0 offered the ``keep alive'' header field as an option, in HTTP/1.1 the default is to keep the connection alive for a certain time of inactivity of the client (usually 15 seconds). We also simplified the behavior of the browser: Since Netscape's browser replaced Mosaic, a browser usually reacts to its user's activities while loading images.

Figure 2.2: Behavior of a simple HTTP server (View PDF)

The dynamic structure diagram in figure 2.2 shows the behavior of the server in more detail: After initialization, the server enters the request-response loop. It waits for an incoming request, examines it2.1, maps the resource to a file and delivers it to the browser. Finally it closes the connection to the client.

It is easy to implement an HTTP server displaying the behavior in figure 2.2 in about 100 lines of code (see appendix B.1 for the code). A productive HTTP server is far more complex for various reasons:

Additional Features

Operation of the server

Portability and installation procedure


... it2.1
only the processing of the GET method is shown in detail.

next up previous contents index
Next: 2.3 Protocols and Standards Up: 2. HTTP Servers Previous: 2.1 Introduction   Contents   Index
Apache Modeling Portal Home Apache Modeling Portal