Write CGI programs with Delphi (3)

zhaozj2021-02-17  54

Write CGI programs with Delphi (3)

Also, each reader feels that the CGI program has a mission, in which this part will tell a basic programming process that is related to the CGI program. After you read it, you will not have a sense of mission. 3. His question of CGI specification: Also per reader feels that the CGI program has a mission, in which this part will tell a basic programming process that is related to the CGI program. After you read it, you will not have a sense of mission. First, when you enter any programming workers, a big task is divided into many small tasks, and each small task is completed into an independent function. Many people don't want to write CGI schemes, because it is difficult to make CGI programming. In fact, divide a typical CGI program into the following parts, then solve it, you will not feel difficult to the CGI program: Overall, when calling a CGI program in the browser, the server first wants to find the CGI program. , In general, the CGI program is placed in the directory specified by the server. In our OMNIHTTPD, in the actual directory specified by the CGI-BIN and the CGI-WIN virtual directory, it is C: / HTTPD / CGI-BIN and C: / httpd / cgi-win directory. You can modify the actual directory in omnihttpd, you can also add a virtual directory, such as: Specifying the virtual directory CGI-TEST as C: / My-CGI; if you have a name Test1.cgi in the C: / My-CGI directory The CGI program, you can call it through the address http://localhost/cgi-test/test1.cgi in the browser. In normal conditions, the server finds a CGI program requested by the browser, and generates an process of this CGI program. In this way, the browser and the server have established a good connection. Once the CGI program is finished, this process will disappear, and it is also lost. All operations in the above picture are completed within the time of the connection, so the tasks that each CGI program completed should be as small as possible, otherwise, the server's large amount of time and resources will be occupied, the client browser waiting time It will be very long. In the above figure, you can see that the CGI program is divided into data input, data processing and data output three parts; when there is, it is necessary to interact with the data in the data in data (CGI program). In these three parts, the data input and data output has a strict specification, and the data is handled by you.

Next, I will re-talk about the specification of data input and data output: In the case, we have listed the almost all environmental variables used in the CGI program. Among them, there is a phase of a part of the same amount of infusion and output has a dense correlation. Under the surface, we would classify lists the variables environment in which the most commonly used: variable environments and server-related: variable environment GATEWAY_INTERFACESERVER_NAMESERVER_PORTSERVER_PROTOCOLSERVER_SOFTWARE and client-related: HTTP_ACCEPTHTTP_ACCEPT_ENCODINGHTTP_ACCEPT_LANGUAGEHTTP_AUTHORIZATIONHTTP_CHARGE_TOHTTP_FROMHTTP_IF_MODIFIED_SINCEHTTP_PRAGMAHTTP_REFERERHTTP_USER_AGENT and requests related environment variable loop: AUTH_TYPECONTENT_FILECONTENT_LENGTHCONTENT_TYPEOUTPUT_FILEPATH_INFOPATH_TRANSLATEDQUERY_STRINGREMOTE_ADDRREMOTE_USERREQUEST_LINEREQUEST_METHODSCRIPT_NAME this was worth Description is CONTENT_FILE and OUTPUT_FILE. There are not many languages ​​on Windows 3.1 and DOS to read and write through the standard input (STDIN and STDOUT), and use these two variables. His environmental variables can be taken as a detailed list before. Introduction, the GET method passes the data through the URL; the POST method is passed through the STDIN transmission data. Nothing is what is the method, the data is passed through the encoded. However, I don't have to worry about the question and decoding issues, because the development language that we will use can be self-operated: in Perl, CGI-LIB.PL is CGI-LIB.PL, which is TWEBModule in Delphi. Head information is also non-important in the CGI programming. The header information is the letter before the CGI program is sent to the customer. There are three major header information types: content-type // Pass htmllocation // to the browser to pass a new urlstatus / / usually in the CGI program to use to check the error content-type is the type of information processing, main Is the type of MIME. The method of definition is a combination of type and sub-type. Common MIME Types include: Text, Multipart, Message, Application, Image, Audio, and Video. For example, the CGI program is to transfer the Text / HTML before passing an HTML document to the browser.

转载请注明原文地址:https://www.9cbs.com/read-30779.html

New Post(0)