Common Gateway Interface

From Just Solve the File Format Problem
Jump to: navigation, search
File Format
Name Common Gateway Interface
Extension(s) .cgi, .fcgi, others

Common Gateway Interface (CGI) is a protocol by which a web server uses a local executable program to handle a request from a web browser.

CGI uses a convenient, if somewhat crude, kind of inter-process communication. For each suitable request it receives, the web server runs a new instance of the CGI handler program. It pipes the body of the request, if any, to the program's standard input stream. All other parameters are communicated via environment variables.

The CGI handler writes its response to its standard output stream, which is read by the web server, and relayed over the network to the web browser.

A file with a .cgi extension might be a CGI handler program (though there are no restrictions on the name of a CGI handler program, other than those imposed by the operating system). If so, it will use a standard executable or scripting file format (such as Perl), not some hypothetical "CGI file format". A .cgi file could also be the saved response from a CGI handler, in which case the most likely format is HTML (though there are no restrictions on the file format of a CGI response).


A variant named FastCGI allows a single process to handle multiple requests. Some other method of inter-process communication is used, such as a Unix domain socket.


Personal tools