What Real Web Servers Do
The Perl server we showed in Example 5-1 is a trivial example web server. State-of-the-art commercial web servers are much more complicated, but they do perform several common tasks, as shown in Figure 5-3:
Figure 5-3. Steps of a basic web server request
Set up connection—accept a client connection, or close if the client is unwanted.
Receive request—read an HTTP request message from the network.
Process request—interpret the request message and take action.
Access resource—access the resource specified in the message.
Construct response—create the HTTP response message with the right headers.
Send response—send the response back to the client.
Log transaction—place notes about the completed transaction in a log file.
The next seven sections highlight how web servers perform these basic tasks.
Get HTTP: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.