1.1.2 HTTP Request Received

The HTTP server, borders.com, receives the HTTP request mentioned in the previous section. It parses the request, and understands the nature of the request. At this point, the server understands that the request is not requesting a static file on the server. Instead, the HTTP request specifies that a server-side script be executed to generate the replying HTML (HyperText Markup Language) document.

How does the server know this request needs to be processed by a CGI script? This is usually done by the extension of the file requested. A static page typically has extensions of htm or html. A CGI page, on the other hand, usually has extensions of cgi, pl, php and etc.

It should be noted that it is often up to the configuration of the HTTP server to decide what is CGI and what is not. Apache, for example, has a rather flexible method to let an administrator specify what extensions correspond to CGI scripts, and how to handle each kind of CGI script. It is possible for an HTTP server to handle different kinds of CGI scripts for the same site.

As soon as the HTTP server realizes the request is for a CGI script, it runs the interpreter (such as Perl) and passes the CGI file to the interpreter. The HTTP server also passes important information, such as the HTTP request itself (often somewhat parsed) along to the script program. At this point, the HTTP server waits for the script to reply with an HTML document, often via the standard output of the script.

Copyright © 2008-05-09 by Tak Auyeung