Write the CGI program with Delphi (2)
In the previous lecture, we introduced the function of the CGI program. Today, we entered: the second part, the concept of CGI program design. The content of this lecture is to understand the basis of the solution of CGI. This series is to write CGI program in Delphi. For this content Delphi, you have been included in its class, you also believe that this is not necessary. But I think that the advantage of CGI is that the available development language is much (this question will be mentioned below), and the content of this lecture can be used in any step set language (including Delphi). In case, it is necessary to play the advantages of CGI. The content of this lecture is still necessary; 2, CGI specification: Tongmong, web server is a powerful plan for a strong function, but it is not possible to use all handling capacity. CGI's production makes people can use the WEB server to provide interesting and dynamic content for remote customers. The CGI specification should be used for Web server and running in the Web. It is not a part of the HTTP protocol, but most of the web servers support this specification, such as NCSA HTTPD, CERN HTTPD, APACHE HTTPD, IIS, and I use OmniHttpd. 2.1, CGI Overview CGI Defining Web Server, Browmers, and Compliance Sets between Same Operations between Shipping. For example, the remote data library system is checked through the web browser: 2.2, words: CGI program can be written in any language that can be implemented on a Web server. You should choose the words that are most familiar with the most familiarity. Such as: Perl language suitable strings and file processing, C to large, complex programs, Visual Basic and Delphi are suitable for processing, etc. The lower surface is commonly used in CGI programming: CC Perltclpythonshell Scriptsvisual BasicDelphiapplescript 2.3, CGI method: The router of the CGI is called the CGI method. There are three kinds of CGI methods: 2.3.1, GET method: The GET method is the method of submitting a request to the web server. When this method is used, the CGI program acquires data from the environmental variable query_string. The CGI program is the parameter that is entered, and this environmental variable must be analyzed. When the data is transmitted, the POST method should be used.
2.3.2, POST method: When the POST method is used, the CGI program is obtained from stdin (standard input) to input data. From the final result of the output, there is no EOF (file end marker end of file), the CGI program is that the orthodont is not read, and the environmental variable content_length value must be used. The maximum advantage of this method is to transmit large amounts of data, while the GET method is limited by the limit of the URL length (generally not over 1024 bytes), and there is no massive data. At this time, the POST method is the only choice. 2.3.3, HEAD method: Head method foundation with the GET method, just it is transmitted from the web server to the browser. Moreover, the transmission is only the header information of HTTP. 2.4, Interface Specification: The following face will introduce the four main methods of Web server and CGI program: the environmental variable, the command line, the standard input and the standard output. (Given according to CGI Version 1.1) 2.4.1, environmental variable: auth_type: If the server is supported, the script is guaranteed, and the confident type is given. Content_length: The data length transmitted by the POST method is given by the pentest. The variable is empty when using the Get method. Content_type: Mine type of data for transmitting data when using the POST method. The variable is empty when the Get method is used. Such as: Application / X-WWW-FORM-URLENCODED. Getway_Interface: gives the CGI regulatory name and version number, such as: CGI / 1.1. Path_INFO: Ges an additional path information after the CGI program name in the URL. PATH_TRANSLATED: The physical path of the CGI program is often the web root of the web root, the script and the attachment path information. Query_String: Information after "?" Characters in the URL. This environment variable is given to the input data when using a GET method. Remote_addr: The IP of the requested remote meter. Remote_host: The name of the requested remote meter. Remote_ident: gives the user name defining in RFC 931. Note: The RFC 931 is the INTERNET's authority document describing the method of confirming TCP connectivity. The document is: http://sunsite.auc.dk/rfc/rfc/rfc931.html. Remote_user: Given the authority of the customer's access to the request.
Request_method: Summary, can be GET, HEAD, and POST. Script_name: To execute the virtual path of the CGI program, such as /cgi-bin/query.cgi. Server_name: Run Web Server Software Machine Domain Name or IP Address, such as: www.chinabyte.com. Server_port: The port number of the web server, the default value is 80. Server_Protocol: Web server uses the protocol name and version number, such as: httpd / 1.0. Server_software: Execute the name of the WEB server of the CGI program. The format is "server name / version number", such as: NCSA / 1.5B5. HTTP_ACCEPT: "Accert: Title Row" sent by the client, corresponding to the MIME type of the client, "type / subtype, type / subtype, etc.", like: * / *, image / gif, image / JPEG. HTTP_REFERER: Yes Referr: Title Target, contains the URL of form (form) when CGI requests, such as http://www.formyte.com/register.form. HTTP_USER_AGENT: Seveled a request for a customer name, such as: Mozilla / 1.2N (Windows; i; 32bit). These environmental variables can be seen in the preface of the above. 2.4.2, command line: The CGI command line is only used when using IsIndex queries. Isindex query is a special check in