Operation of a CGI Script
At the most basic level, a CGI script must
- Parse the input (the form data) from the server, and
- Generate a response.
Most often the response is the text of a dynamically generated HTML document, preceded by some HTTP headers.
- In practice the only required HTTP header is the Content-type header. The Web Server will fill in other necessary headers automatically.
Even if there is no meaningful response to the input data, the CGI script must output an empty message, or some error message.
- Otherwise the server will not close the connection to the client, and a browser error will occur.