CGI development is too complex in some ways, mainly because it is used to obtain environment variables and decompose/decode data. In Windows, you can use WinCGI for development. The advantage of WinCGI is that it reduces the burden on developers to break down/decode data and provides a unified input/output method.
InDuring WinCGI program execution, the first parameter is a file name, for example, yourCGI.exe para.txt. All environment variables and parameter information are recorded in this file, the structure of the file is the same as that of the INI file. Therefore, all parameters can be retrieved using the standard function GetPrivateProfileString provided by Windows. In addition, all the data in the file has been decoded and can be directly used.
The parameter file contains the following areas (Section)
- [CGI]
- [Accept]
- [System]
- [Extra Headers]
- [Form Literal]
- [Form External]
- [Form File]
- [Form Huge]
The file format is as follows:
[CGI]
CGI Version = CGI/1.2 (Win)
Query String = XXXXXX
[Section]
Key = value
Key = value
...
The following data is particularly useful to us in this parameter file:
The keywords in the [CGI] area record the system parameters, the browser of the other party, the IP address of the other party, and other information. Some common keywords are listed below:
- Request Method: data transmission Method. If the transmission Method is GET, you can also check the value of the Query String keyword to obtain the transmitted data, otherwise, you must read the [Form Literal] area to obtain the input.
- Request Protocol: the Protocol and version used, such as HTTP/1.0.
- From: The email address of the browser user.