annotate Doc/lib/libcgihttp.tex @ 13625:fdfd1049f36e legacy-trunk

Rob W. W. Hooft's spelling fixes for the Library Reference. I hope SourceForge doesn't choke on this batch :-) I'm not entirely sure this is 100% correct. The patch changes an \index{persistency} to \index{presistence}, and I don't know what \index{} does. But it seems to do so persi--er, consistently, so I hope it isn't a problem.
author Thomas Wouters <thomas@python.org>
date Sun, 16 Jul 2000 19:01:10 +0000
parents e82e82b3b9ad
children dd49f29d9879
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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} ---
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 A Do-Something Request Handler}
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}
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7 \sectionauthor{Moshe Zadka}{mzadka@geocities.com}
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
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
18 \strong{Note:} This module is \UNIX{} dependent since it creates the
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
19 CGI process using \function{os.fork()} and \function{os.exec()}.
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}