Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libcgihttp.tex @ 20580:376ee174ecd0 legacy-trunk
Use the \note and \warning macros where appropriate.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Sat, 20 Oct 2001 04:24:09 +0000 |
| parents | d7864345b1c8 |
| children | 42365b70e9d8 |
| rev | line source |
|---|---|
|
10982
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
1 \section{\module{CGIHTTPServer} --- |
|
15139
dd49f29d9879
Better synopses based on suggestions from Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
2 CGI-capable HTTP request handler} |
|
10982
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
3 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
4 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
5 \declaremodule{standard}{CGIHTTPServer} |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10982
diff
changeset
|
6 \platform{Unix} |
|
15467
d7864345b1c8
Update Moshe Zadka's email address to one works and might last a while.
Fred Drake <fdrake@acm.org>
parents:
15139
diff
changeset
|
7 \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} |
|
10982
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
8 \modulesynopsis{This module provides a request handler for HTTP servers |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
9 which can run CGI scripts.} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
10 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
11 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
12 The \module{CGIHTTPServer} module defines a request-handler class, |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
13 interface compatible with |
|
13625
fdfd1049f36e
Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents:
12223
diff
changeset
|
14 \class{BaseHTTPServer.BaseHTTPRequestHandler} and inherits behavior |
|
10982
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
15 from \class{SimpleHTTPServer.SimpleHTTPRequestHandler} but can also |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
16 run CGI scripts. |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
17 |
|
20580
376ee174ecd0
Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents:
15467
diff
changeset
|
18 \note{This module is \UNIX{} dependent since it creates the |
|
376ee174ecd0
Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents:
15467
diff
changeset
|
19 CGI process using \function{os.fork()} and \function{os.exec()}.} |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10982
diff
changeset
|
20 |
|
10982
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
21 The \module{CGIHTTPServer} module defines the following class: |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
22 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
23 \begin{classdesc}{CGIHTTPRequestHandler}{request, client_address, server} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
24 This class is used to serve either files or output of CGI scripts from |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
25 the current directory and below. Note that mapping HTTP hierarchic |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
26 structure to local directory structure is exactly as in |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
27 \class{SimpleHTTPServer.SimpleHTTPRequestHandler}. |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
28 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
29 The class will however, run the CGI script, instead of serving it as a |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
30 file, if it guesses it to be a CGI script. Only directory-based CGI |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
31 are used --- the other common server configuration is to treat special |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
32 extensions as denoting CGI scripts. |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
33 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
34 The \function{do_GET()} and \function{do_HEAD()} functions are |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
35 modified to run CGI scripts and serve the output, instead of serving |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
36 files, if the request leads to somewhere below the |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
37 \code{cgi_directories} path. |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
38 \end{classdesc} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
39 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
40 The \class{CGIHTTPRequestHandler} defines the following data member: |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
41 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
42 \begin{memberdesc}{cgi_directories} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
43 This defaults to \code{['/cgi-bin', '/htbin']} and describes |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
44 directories to treat as containing CGI scripts. |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
45 \end{memberdesc} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
46 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
47 The \class{CGIHTTPRequestHandler} defines the following methods: |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
48 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
49 \begin{methoddesc}{do_POST}{} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
50 This method serves the \code{'POST'} request type, only allowed for |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
51 CGI scripts. Error 501, "Can only POST to CGI scripts", is output |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
52 when trying to POST to a non-CGI url. |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
53 \end{methoddesc} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
54 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
55 Note that CGI scripts will be run with UID of user nobody, for security |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
56 reasons. Problems with the CGI script will be translated to error 403. |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
57 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
58 For example usage, see the implementation of the \function{test()} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
59 function. |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
60 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
61 |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
62 \begin{seealso} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
63 \seemodule{BaseHTTPServer}{Base class implementation for Web server |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
64 and request handler.} |
|
bef46ea5ef75
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
65 \end{seealso} |
