Figure 5.1 depicts the stages in an HTTP transaction that include a CGI script.
Figure 5.1. HTTP transactions with CGI scripts.
Note:
A URI, or Uniform Resource Identifier, simply refers to the formatted string that references a specific network resource. URIs have been known by many names:
WWW AddressNetsite
Uniform Resource Locator (URL)
Uniform Resource Name (URN)
Universal Document Identifiers
Certain data and variables are passed between the browser and the server during each step of an HTTP transaction. A transaction is the process that begins with typing a URI (http://www.coolsite.com/index.html
) into a Web browser and ends with the Web server sending the appropriate response. That response is usually just a Web page or a GIF image but can be anything from the output of a CGI Perl5 script to a stream of video. The data and variables, or messages, passed back and forth between the browser and the server during the transaction are called HTTP headers. Understanding the details of the HTTP transaction and being aware of the syntax and content of these headers is critical. The content of these headers is made available by the Web server in the form of environment variables to your CGI. Using information obtained from these environment variables, you could, for example, send out different Web pages based on what kind of Web browser someone is using. Let's now explore the interaction between the browser, also known as the client, and the Web server during a typical HTTP transaction.