This section describes what is CGI (Common Gateway Interface) - a protocol defines how a Web server program interacts with application programs.
Common Gateway Interface (CGI) is a protocol that defines how a Web server program
interacts with application programs. The interactions are illustrated in the
following diagram:
Web Web CGI Appl.
Browser Internet Server Protocol Program
HTTP Env. Var.
request stdin
Send --------------> Convert ----------> Process
|
HTTP |
response stdout V
Receive <----------- Convert <---------- Process
There are several basic rules with CGI:
Web server provides most of the input information
to application programs through environment variables.
Data send in the HTTP request with the GET method is converted to
a special environment variable, QUERY_STRING.
Data send in the HTTP request with the POST method is converted to
the standard input (stdin) channel.
Data printed to the standard output (stdout) channel is converted
to the HTTP response.