|
Delphi Internet | Tips & Tricks | Bug List | Cool Delphi Sites | What happens when a CGI script is called?The following diagram briefly outlines the machinations that underlie a typical CGI transaction. The browser triggers an event -- usually through a form submission -- that causes the WWW server to execute a program rather than return an HTML document. The server packages the pertinent CGI information and the client's data and outputs it to a file in a temporary directory. The name of the file is passed as a parameter to the CGI executable. If the CGI script is entitled POSTDATA.EXE, then the information that is passed by the server to the operating system could be conceptualized as follows. . . "postdata tempfilename". Your CGI program can read the tempfilename as from parameter string, that's how the CGI program learns where to look for the client data. That temp file also passes a suite of other important facts to your program, including the name of the output file and where the server expects to find the data when you are done processing it. Your code reads the data out of the temp file. When you are done processing the data, your results are written to the temporary output file. When the server detects that the process has finished running, it reads the temp file, passes the data to the browser, and then erases the temp file. The Temp File The listing below is taken from an actual temp file that was created on my system. The name of the file was C:\TEMP\63WS.INI -- the name was assigned by WebSite. Note that this is the normal INI structure with [SECTION HEADINGS] in brackets and key=value pairs listed in their respective sections. If you look in the [FORM LITERAL] section you will see that the browser filled out a form that asked for name and email information. In the [SYSTEM] section you will find the input and output file name; my CGI script read the data right out of the key value pairs in this file, I did not read the 63WS.INP file. I returned my data to 63WS.OUT. [CGI] Summary As you can see the process is relatively simple. The browser (probably Netscape) triggers WebSite to execute a script. WebSite calls the executable file and passes it the CGI data in a temp file. The CGI executable reads the temp file, processes the data and writes its output to a temp file. When WebSite detects that the CGI script has ceased (it finds the expected output file returned by the CGI code), it retrieves the data from the executable and then sends the data to the browser. Don't worry about the details yet, just try to visual a figurative model for the major steps. | Borland Delphi | About the Authors | Home | For Queries Mail To Webmaster Copyright © 1996 Asylum Software Pvt. Ltd. This is an ASPL production. |