annotate Doc/lib/libcgihttp.tex @ 24042:63fbbed10714 legacy-trunk

Simplify HTTPSConnection constructor. See discussion in SF bug 458463.
author Jeremy Hylton <jeremy@alum.mit.edu>
date Fri, 28 Jun 2002 23:38:14 +0000
parents 42365b70e9d8
children ec1925f07ec9
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} ---
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}
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
6 \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
7 \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
8 which can run CGI scripts.}
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9
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 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
12 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
13 \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
14 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
15 run CGI scripts.
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16
21018
42365b70e9d8 Update the platform notes for the CGIHTTPServer module; it works on more
Fred Drake <fdrake@acm.org>
parents: 20580
diff changeset
17 \note{This module can run CGI scripts on \UNIX{} and Windows systems;
42365b70e9d8 Update the platform notes for the CGIHTTPServer module; it works on more
Fred Drake <fdrake@acm.org>
parents: 20580
diff changeset
18 on Mac OS it will only be able to run Python scripts within the same
42365b70e9d8 Update the platform notes for the CGIHTTPServer module; it works on more
Fred Drake <fdrake@acm.org>
parents: 20580
diff changeset
19 process as itself.}
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}