diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-11 14:52:07 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-11 14:52:07 +0000 |
commit | 136f42f503cb3e9588e62332d043e92b7475ec4e (patch) | |
tree | 81c556d1a136112be07bbd2c19293e65fad03cdd /docs/cgi | |
parent | ad67a3925c78e7c9f8e61248f640c5cc7a5cf186 (diff) | |
download | busybox-w32-136f42f503cb3e9588e62332d043e92b7475ec4e.tar.gz busybox-w32-136f42f503cb3e9588e62332d043e92b7475ec4e.tar.bz2 busybox-w32-136f42f503cb3e9588e62332d043e92b7475ec4e.zip |
Add CGI docs
Diffstat (limited to 'docs/cgi')
-rw-r--r-- | docs/cgi/cl.html | 46 | ||||
-rw-r--r-- | docs/cgi/env.html | 149 | ||||
-rw-r--r-- | docs/cgi/in.html | 33 | ||||
-rw-r--r-- | docs/cgi/interface.html | 29 | ||||
-rw-r--r-- | docs/cgi/out.html | 126 |
5 files changed, 383 insertions, 0 deletions
diff --git a/docs/cgi/cl.html b/docs/cgi/cl.html new file mode 100644 index 000000000..5779d623e --- /dev/null +++ b/docs/cgi/cl.html | |||
@@ -0,0 +1,46 @@ | |||
1 | <html><head><title>CGI Command line options</title></head><body><h1><img alt="" src="cl_files/CGIlogo.gif"> CGI Command line options</h1> | ||
2 | <hr> <p> | ||
3 | |||
4 | </p><h2>Specification</h2> | ||
5 | |||
6 | The command line is only used in the case of an ISINDEX query. It is | ||
7 | not used in the case of an HTML form or any as yet undefined query | ||
8 | type. The server should search the query information (the <code>QUERY_STRING</code> environment variable) for a non-encoded | ||
9 | = character to determine if the command line is to be used, if it | ||
10 | finds one, the command line is not to be used. This trusts the clients | ||
11 | to encode the = sign in ISINDEX queries, a practice which was | ||
12 | considered safe at the time of the design of this specification. <p> | ||
13 | |||
14 | For example, use the <a href="http://hoohoo.ncsa.uiuc.edu/cgi-bin/finger">finger script</a> and the ISINDEX interface to look up "httpd". You will see that the script will call itself with <code>/cgi-bin/finger?httpd</code> and will actually execute "finger httpd" on the command line and output the results to you. | ||
15 | </p><p> | ||
16 | If the server does find a "=" in the <code>QUERY_STRING</code>, | ||
17 | then the command line will not be used, and no decoding will be | ||
18 | performed. The query then remains intact for processing by an | ||
19 | appropriate FORM submission decoder. | ||
20 | Again, as an example, use <a href="http://hoohoo.ncsa.uiuc.edu/cgi-bin/finger?httpd=name">this hyperlink</a> to submit <code>"httpd=name"</code> to the finger script. Since this <code>QUERY_STRING</code> | ||
21 | contained an unencoded "=", nothing was decoded, the script didn't know | ||
22 | it was being submitted a valid query, and just gave you the default | ||
23 | finger form. | ||
24 | </p><p> | ||
25 | If the server finds that it cannot send the string due to internal | ||
26 | limitations (such as exec() or /bin/sh command line restrictions) the | ||
27 | server should include NO command line information and provide the | ||
28 | non-decoded query information in the environment | ||
29 | variable <a href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html#query"><code>QUERY_STRING</code></a>. </p><p> | ||
30 | </p><hr> | ||
31 | <h2>Examples</h2> | ||
32 | |||
33 | Examples of the command line usage are much better <a href="http://hoohoo.ncsa.uiuc.edu/cgi/examples.html">demonstrated</a> than explained. For these | ||
34 | examples, pay close attention to the script output which says what | ||
35 | argc and argv are. <p> | ||
36 | |||
37 | </p><hr> | ||
38 | |||
39 | <a href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html"><img alt="[Back]" src="cl_files/back.gif">Return to the | ||
40 | interface specification</a> <p> | ||
41 | |||
42 | CGI - Common Gateway Interface | ||
43 | </p><address><a href="http://hoohoo.ncsa.uiuc.edu/cgi/mailtocgi.html">cgi@ncsa.uiuc.edu</a></address> | ||
44 | |||
45 | |||
46 | </body></html> \ No newline at end of file | ||
diff --git a/docs/cgi/env.html b/docs/cgi/env.html new file mode 100644 index 000000000..961671aaa --- /dev/null +++ b/docs/cgi/env.html | |||
@@ -0,0 +1,149 @@ | |||
1 | <html><head><title>CGI Environment Variables</title></head><body><h1><img alt="" src="env_files/CGIlogo.gif"> CGI Environment Variables</h1> | ||
2 | <hr> | ||
3 | |||
4 | <p> | ||
5 | |||
6 | In order to pass data about the information request from the server to | ||
7 | the script, the server uses command line arguments as well as | ||
8 | environment variables. These environment variables are set when the | ||
9 | server executes the gateway program. </p><p> | ||
10 | |||
11 | </p><hr> | ||
12 | <h2>Specification</h2> | ||
13 | |||
14 | <p> | ||
15 | The following environment variables are not request-specific and are | ||
16 | set for all requests: </p><p> | ||
17 | |||
18 | </p><ul> | ||
19 | <li> <code>SERVER_SOFTWARE</code> <p> | ||
20 | |||
21 | The name and version of the information server software answering | ||
22 | the request (and running the gateway). Format: name/version </p><p> | ||
23 | |||
24 | </p></li><li> <code>SERVER_NAME</code> <p> | ||
25 | The server's hostname, DNS alias, or IP address as it would appear | ||
26 | in self-referencing URLs. </p><p> | ||
27 | |||
28 | </p></li><li> <code>GATEWAY_INTERFACE</code> <p> | ||
29 | The revision of the CGI specification to which this server | ||
30 | complies. Format: CGI/revision</p><p> | ||
31 | |||
32 | </p></li></ul> | ||
33 | |||
34 | <hr> | ||
35 | |||
36 | The following environment variables are specific to the request being | ||
37 | fulfilled by the gateway program: <p> | ||
38 | |||
39 | </p><ul> | ||
40 | <li> <a name="protocol"><code>SERVER_PROTOCOL</code></a> <p> | ||
41 | The name and revision of the information protcol this request came | ||
42 | in with. Format: protocol/revision </p><p> | ||
43 | |||
44 | </p></li><li> <code>SERVER_PORT</code> <p> | ||
45 | The port number to which the request was sent. </p><p> | ||
46 | |||
47 | </p></li><li> <code>REQUEST_METHOD</code> <p> | ||
48 | The method with which the request was made. For HTTP, this is | ||
49 | "GET", "HEAD", "POST", etc. </p><p> | ||
50 | |||
51 | </p></li><li> <code>PATH_INFO</code> <p> | ||
52 | The extra path information, as given by the client. In other | ||
53 | words, scripts can be accessed by their virtual pathname, followed | ||
54 | by extra information at the end of this path. The extra | ||
55 | information is sent as PATH_INFO. This information should be | ||
56 | decoded by the server if it comes from a URL before it is passed | ||
57 | to the CGI script.</p><p> | ||
58 | |||
59 | </p></li><li> <code>PATH_TRANSLATED</code> <p> | ||
60 | The server provides a translated version of PATH_INFO, which takes | ||
61 | the path and does any virtual-to-physical mapping to it. </p><p> | ||
62 | |||
63 | </p></li><li> <code>SCRIPT_NAME</code> <p> | ||
64 | A virtual path to the script being executed, used for | ||
65 | self-referencing URLs. </p><p> | ||
66 | |||
67 | </p></li><li> <a name="query"><code>QUERY_STRING</code></a> <p> | ||
68 | The information which follows the ? in the <a href="http://www.ncsa.uiuc.edu/demoweb/url-primer.html">URL</a> | ||
69 | which referenced this script. This is the query information. It | ||
70 | should not be decoded in any fashion. This variable should always | ||
71 | be set when there is query information, regardless of <a href="http://hoohoo.ncsa.uiuc.edu/cgi/cl.html">command line decoding</a>. </p><p> | ||
72 | |||
73 | </p></li><li> <code>REMOTE_HOST</code> <p> | ||
74 | The hostname making the request. If the server does not have this | ||
75 | information, it should set REMOTE_ADDR and leave this unset.</p><p> | ||
76 | |||
77 | </p></li><li> <code>REMOTE_ADDR</code> <p> | ||
78 | The IP address of the remote host making the request. </p><p> | ||
79 | |||
80 | </p></li><li> <code>AUTH_TYPE</code> <p> | ||
81 | If the server supports user authentication, and the script is | ||
82 | protects, this is the protocol-specific authentication method used | ||
83 | to validate the user. </p><p> | ||
84 | |||
85 | </p></li><li> <code>REMOTE_USER</code> <p> | ||
86 | If the server supports user authentication, and the script is | ||
87 | protected, this is the username they have authenticated as. </p><p> | ||
88 | </p></li><li> <code>REMOTE_IDENT</code> <p> | ||
89 | If the HTTP server supports RFC 931 identification, then this | ||
90 | variable will be set to the remote user name retrieved from the | ||
91 | server. Usage of this variable should be limited to logging only. | ||
92 | </p><p> | ||
93 | |||
94 | </p></li><li> <a name="ct"><code>CONTENT_TYPE</code></a> <p> | ||
95 | For queries which have attached information, such as HTTP POST and | ||
96 | PUT, this is the content type of the data. </p><p> | ||
97 | |||
98 | </p></li><li> <a name="cl"><code>CONTENT_LENGTH</code></a> <p> | ||
99 | The length of the said content as given by the client. </p><p> | ||
100 | |||
101 | </p></li></ul> | ||
102 | |||
103 | |||
104 | <a name="headers"><hr></a> | ||
105 | |||
106 | In addition to these, the header lines received from the client, if | ||
107 | any, are placed into the environment with the prefix HTTP_ followed by | ||
108 | the header name. Any - characters in the header name are changed to _ | ||
109 | characters. The server may exclude any headers which it has already | ||
110 | processed, such as Authorization, Content-type, and Content-length. If | ||
111 | necessary, the server may choose to exclude any or all of these | ||
112 | headers if including them would exceed any system environment | ||
113 | limits. <p> | ||
114 | |||
115 | An example of this is the HTTP_ACCEPT variable which was defined in | ||
116 | CGI/1.0. Another example is the header User-Agent.</p><p> | ||
117 | |||
118 | </p><ul> | ||
119 | <li> <code>HTTP_ACCEPT</code> <p> | ||
120 | The MIME types which the client will accept, as given by HTTP | ||
121 | headers. Other protocols may need to get this information from | ||
122 | elsewhere. Each item in this list should be separated by commas as | ||
123 | per the HTTP spec. </p><p> | ||
124 | |||
125 | Format: type/subtype, type/subtype </p><p> | ||
126 | |||
127 | |||
128 | </p></li><li> <code>HTTP_USER_AGENT</code><p> | ||
129 | |||
130 | The browser the client is using to send the request. General | ||
131 | format: <code>software/version library/version</code>.</p><p> | ||
132 | |||
133 | </p></li></ul> | ||
134 | |||
135 | <hr> | ||
136 | <h2>Examples</h2> | ||
137 | |||
138 | Examples of the setting of environment variables are really much better | ||
139 | <a href="http://hoohoo.ncsa.uiuc.edu/cgi/examples.html">demonstrated</a> than explained. <p> | ||
140 | |||
141 | </p><hr> | ||
142 | |||
143 | <a href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html"><img alt="[Back]" src="env_files/back.gif">Return to the | ||
144 | interface specification</a> <p> | ||
145 | |||
146 | CGI - Common Gateway Interface | ||
147 | </p><address><a href="http://hoohoo.ncsa.uiuc.edu/cgi/mailtocgi.html">cgi@ncsa.uiuc.edu</a></address> | ||
148 | |||
149 | </body></html> \ No newline at end of file | ||
diff --git a/docs/cgi/in.html b/docs/cgi/in.html new file mode 100644 index 000000000..679306aaa --- /dev/null +++ b/docs/cgi/in.html | |||
@@ -0,0 +1,33 @@ | |||
1 | <html><head><title>CGI Script input</title></head><body><h1><img alt="" src="in_files/CGIlogo.gif"> CGI Script Input</h1> | ||
2 | <hr> | ||
3 | |||
4 | <h2>Specification</h2> | ||
5 | |||
6 | For requests which have information attached after the header, such as | ||
7 | HTTP POST or PUT, the information will be sent to the script on stdin. | ||
8 | <p> | ||
9 | |||
10 | The server will send <a href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html#cl">CONTENT_LENGTH</a> bytes on | ||
11 | this file descriptor. Remember that it will give the <a href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html#ct">CONTENT_TYPE</a> of the data as well. The server is | ||
12 | in no way obligated to send end-of-file after the script reads | ||
13 | <code>CONTENT_LENGTH</code> bytes. </p><p> | ||
14 | </p><hr> | ||
15 | <h2>Example</h2> | ||
16 | |||
17 | Let's take a form with METHOD="POST" as an example. Let's say the form | ||
18 | results are 7 bytes encoded, and look like <code>a=b&b=c</code>. | ||
19 | <p> | ||
20 | |||
21 | In this case, the server will set CONTENT_LENGTH to 7 and CONTENT_TYPE | ||
22 | to application/x-www-form-urlencoded. The first byte on the script's | ||
23 | standard input will be "a", followed by the rest of the encoded string.</p><p> | ||
24 | |||
25 | </p><hr> | ||
26 | |||
27 | <a href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html"><img alt="[Back]" src="in_files/back.gif">Return to the | ||
28 | interface specification</a> <p> | ||
29 | |||
30 | CGI - Common Gateway Interface | ||
31 | </p><address><a href="http://hoohoo.ncsa.uiuc.edu/cgi/mailtocgi.html">cgi@ncsa.uiuc.edu</a></address> | ||
32 | |||
33 | </body></html> \ No newline at end of file | ||
diff --git a/docs/cgi/interface.html b/docs/cgi/interface.html new file mode 100644 index 000000000..33f02881b --- /dev/null +++ b/docs/cgi/interface.html | |||
@@ -0,0 +1,29 @@ | |||
1 | <html><head><title>The Common Gateway Interface Specification | ||
2 | [http://hoohoo.ncsa.uiuc.edu/cgi/interface.html] | ||
3 | </title></head><body><h1><img alt="" src="interface_files/CGIlogo.gif"> The CGI Specification</h1> | ||
4 | |||
5 | <hr> | ||
6 | |||
7 | This is the specification for CGI version 1.1, or CGI/1.1. Further | ||
8 | revisions of this protocol are guaranteed to be backward compatible. | ||
9 | <p> | ||
10 | |||
11 | The server and the CGI script communicate in four major ways. Each of | ||
12 | the following is a hotlink to graphic detail.</p><p> | ||
13 | |||
14 | </p><ul> | ||
15 | <li> <a href="env.html">Environment variables</a> | ||
16 | </li><li> <a href="cl.html">The command line</a> | ||
17 | </li><li> <a href="in.html">Standard input</a> | ||
18 | </li><li> <a href="out.html">Standard output</a> | ||
19 | </li></ul> | ||
20 | <hr> | ||
21 | |||
22 | |||
23 | <a href="http://hoohoo.ncsa.uiuc.edu/cgi/overview.html"><img alt="[Back]" src="interface_files/back.gif">Return to the overview</a> <p> | ||
24 | |||
25 | |||
26 | |||
27 | CGI - Common Gateway Interface | ||
28 | </p><address><a href="http://hoohoo.ncsa.uiuc.edu/cgi/mailtocgi.html">cgi@ncsa.uiuc.edu</a></address> | ||
29 | </body></html> \ No newline at end of file | ||
diff --git a/docs/cgi/out.html b/docs/cgi/out.html new file mode 100644 index 000000000..2203ee5a0 --- /dev/null +++ b/docs/cgi/out.html | |||
@@ -0,0 +1,126 @@ | |||
1 | <html><head><title>CGI Script output</title></head><body><h1><img alt="" src="out_files/CGIlogo.gif"> CGI Script Output</h1> | ||
2 | <hr> | ||
3 | |||
4 | <h2>Script output</h2> | ||
5 | |||
6 | The script sends its output to stdout. This output can either be a | ||
7 | document generated by the script, or instructions to the server for | ||
8 | retrieving the desired output. <p> | ||
9 | </p><hr> | ||
10 | |||
11 | <h2>Script naming conventions</h2> | ||
12 | |||
13 | Normally, scripts produce output which is interpreted and sent back to | ||
14 | the client. An advantage of this is that the scripts do not need to | ||
15 | send a full HTTP/1.0 header for every request. <p> | ||
16 | <a name="nph"> | ||
17 | Some scripts may want to avoid the extra overhead of the server | ||
18 | parsing their output, and talk directly to the client. In order to | ||
19 | distinguish these scripts from the other scripts, CGI requires that | ||
20 | the script name begins with nph- if a script does not want the server | ||
21 | to parse its header. In this case, it is the script's responsibility | ||
22 | to return a valid HTTP/1.0 (or HTTP/0.9) response to the client. </a></p><p> | ||
23 | |||
24 | </p><hr> | ||
25 | <h2><a name="nph">Parsed headers</a></h2> | ||
26 | |||
27 | <a name="nph">The output of scripts begins with a small header. This header consists | ||
28 | of text lines, in the same format as an </a><a href="http://www.w3.org/hypertext/WWW/Protocols/HTTP/Object_Headers.html"> | ||
29 | HTTP header</a>, terminated by a blank line (a line with only a | ||
30 | linefeed or CR/LF). <p> | ||
31 | |||
32 | Any headers which are not server directives are sent directly back to | ||
33 | the client. Currently, this specification defines three server | ||
34 | directives:</p><p> | ||
35 | |||
36 | </p><ul> | ||
37 | <li> <code>Content-type</code> <p> | ||
38 | |||
39 | This is the MIME type of the document you are returning. </p><p> | ||
40 | |||
41 | </p></li><li> <code>Location</code> <p> | ||
42 | |||
43 | This is used to specify to the server that you are returning a | ||
44 | reference to a document rather than an actual document. </p><p> | ||
45 | |||
46 | If the argument to this is a URL, the server will issue a redirect | ||
47 | to the client. </p><p> | ||
48 | |||
49 | If the argument to this is a virtual path, the server will | ||
50 | retrieve the document specified as if the client had requested | ||
51 | that document originally. ? directives will work in here, but # | ||
52 | directives must be redirected back to the client.</p><p> | ||
53 | |||
54 | |||
55 | </p></li><li> <a name="status"><code>Status</code></a><p> | ||
56 | |||
57 | This is used to give the server an HTTP/1.0 <a href="http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRESP.html">status | ||
58 | line</a> to send to the client. The format is <code>nnn xxxxx</code>, | ||
59 | where <code>nnn</code> is the 3-digit status code, and | ||
60 | <code>xxxxx</code> is the reason string, such as "Forbidden".</p><p> | ||
61 | |||
62 | </p></li></ul> | ||
63 | |||
64 | <hr> | ||
65 | <h2>Examples</h2> | ||
66 | |||
67 | Let's say I have a fromgratz to HTML converter. When my converter is | ||
68 | finished with its work, it will output the following on stdout (note | ||
69 | that the lines beginning and ending with --- are just for illustration | ||
70 | and would not be output): <p> | ||
71 | |||
72 | </p><pre>--- start of output --- | ||
73 | Content-type: text/html | ||
74 | |||
75 | --- end of output --- | ||
76 | </pre> | ||
77 | |||
78 | Note the blank line after Content-type. <p> | ||
79 | |||
80 | Now, let's say I have a script which, in certain instances, wants to | ||
81 | return the document <code>/path/doc.txt</code> from this server just | ||
82 | as if the user had actually requested | ||
83 | <code>http://server:port/path/doc.txt</code> to begin with. In this | ||
84 | case, the script would output: </p><p> | ||
85 | </p><pre>--- start of output --- | ||
86 | Location: /path/doc.txt | ||
87 | |||
88 | --- end of output --- | ||
89 | </pre> | ||
90 | |||
91 | The server would then perform the request and send it to the client. | ||
92 | <p> | ||
93 | |||
94 | Let's say that I have a script which wants to reference our gopher | ||
95 | server. In this case, if the script wanted to refer the user to | ||
96 | <code>gopher://gopher.ncsa.uiuc.edu/</code>, it would output: </p><p> | ||
97 | |||
98 | </p><pre>--- start of output --- | ||
99 | Location: gopher://gopher.ncsa.uiuc.edu/ | ||
100 | |||
101 | --- end of output --- | ||
102 | </pre> | ||
103 | |||
104 | Finally, I have a script which wants to talk to the client directly. | ||
105 | In this case, if the script is referenced with <a href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html#protocol"><code>SERVER_PROTOCOL</code></a> of HTTP/1.0, | ||
106 | the script would output the following HTTP/1.0 response: <p> | ||
107 | |||
108 | </p><pre>--- start of output --- | ||
109 | HTTP/1.0 200 OK | ||
110 | Server: NCSA/1.0a6 | ||
111 | Content-type: text/plain | ||
112 | |||
113 | This is a plaintext document generated on the fly just for you. | ||
114 | |||
115 | --- end of output --- | ||
116 | </pre> | ||
117 | |||
118 | |||
119 | <hr> | ||
120 | |||
121 | <a href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html"><img alt="[Back]" src="out_files/back.gif">Return to the | ||
122 | interface specification</a> <p> | ||
123 | |||
124 | CGI - Common Gateway Interface | ||
125 | </p><address><a href="http://hoohoo.ncsa.uiuc.edu/cgi/mailtocgi.html">cgi@ncsa.uiuc.edu</a></address> | ||
126 | </body></html> \ No newline at end of file | ||