Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libbasehttp.tex @ 16413:8819867f14ef legacy-trunk
Patch derived from Trent's 101162: a Python/C API testing framework.
STILL NEEDS UNIX BUILD CHANGES.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Fri, 02 Feb 2001 05:57:15 +0000 |
| parents | dd49f29d9879 |
| children | 346dcafc878b |
| rev | line source |
|---|---|
| 8918 | 1 \section{\module{BaseHTTPServer} --- |
|
15139
dd49f29d9879
Better synopses based on suggestions from Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
2 Basic HTTP server} |
|
dd49f29d9879
Better synopses based on suggestions from Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
3 |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7875
diff
changeset
|
4 \declaremodule{standard}{BaseHTTPServer} |
| 8855 | 5 \modulesynopsis{Basic HTTP server (base class for |
|
15139
dd49f29d9879
Better synopses based on suggestions from Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
6 \class{SimpleHTTPServer} and \class{CGIHTTPServer}).} |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7875
diff
changeset
|
7 |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 \indexii{WWW}{server} |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 \indexii{HTTP}{protocol} |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 \index{URL} |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 \index{httpd} |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 This module defines two classes for implementing HTTP servers |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 (web servers). Usually, this module isn't used directly, but is used |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 as a basis for building functioning web servers. See the |
|
10983
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
17 \module{SimpleHTTPServer}\refstmodindex{SimpleHTTPServer} and |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
18 \refmodule{CGIHTTPServer}\refstmodindex{CGIHTTPServer} modules. |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 |
| 7684 | 20 The first class, \class{HTTPServer}, is a |
| 21 \class{SocketServer.TCPServer} subclass. It creates and listens at the | |
| 22 web socket, dispatching the requests to a handler. Code to create and | |
| 23 run the server looks like this: | |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 |
|
7277
bf4e790bd61a
Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents:
7204
diff
changeset
|
25 \begin{verbatim} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 def run(server_class=BaseHTTPServer.HTTPServer, |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 handler_class=BaseHTTPServer.BaseHTTPRequestHandler): |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
28 server_address = ('', 8000) |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
29 httpd = server_class(server_address, handler_class) |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
30 httpd.serve_forever() |
|
7277
bf4e790bd61a
Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents:
7204
diff
changeset
|
31 \end{verbatim} |
| 7684 | 32 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
33 \begin{classdesc}{HTTPServer}{server_address, RequestHandlerClass} |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
34 This class builds on the \class{TCPServer} class by |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 storing the server address as instance |
| 7684 | 36 variables named \member{server_name} and \member{server_port}. The |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 server is accessible by the handler, typically through the handler's |
| 7684 | 38 \member{server} instance variable. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
39 \end{classdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
41 \begin{classdesc}{BaseHTTPRequestHandler}{request, client_address, server} |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
42 This class is used |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 to handle the HTTP requests that arrive at the server. By itself, |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 it cannot respond to any actual HTTP requests; it must be subclassed |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 to handle each request method (e.g. GET or POST). |
| 7684 | 46 \class{BaseHTTPRequestHandler} provides a number of class and instance |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 variables, and methods for use by subclasses. |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 The handler will parse the request and the headers, then call a |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 method specific to the request type. The method name is constructed |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
51 from the request. For example, for the request method \samp{SPAM}, the |
| 7684 | 52 \method{do_SPAM()} method will be called with no arguments. All of |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
53 the relevant information is stored in instance variables of the |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
54 handler. Subclasses should not need to override or extend the |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
55 \method{__init__()} method. |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
56 \end{classdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 |
| 7684 | 59 \class{BaseHTTPRequestHandler} has the following instance variables: |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
61 \begin{memberdesc}{client_address} |
| 7684 | 62 Contains a tuple of the form \code{(\var{host}, \var{port})} referring |
| 63 to the client's address. | |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
64 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
66 \begin{memberdesc}{command} |
| 7684 | 67 Contains the command (request type). For example, \code{'GET'}. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
68 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
70 \begin{memberdesc}{path} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 Contains the request path. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
72 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
74 \begin{memberdesc}{request_version} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 Contains the version string from the request. For example, |
| 7684 | 76 \code{'HTTP/1.0'}. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
77 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
79 \begin{memberdesc}{headers} |
| 7684 | 80 Holds an instance of the class specified by the \member{MessageClass} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 class variable. This instance parses and manages the headers in |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 the HTTP request. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
83 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
85 \begin{memberdesc}{rfile} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 Contains an input stream, positioned at the start of the optional |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 input data. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
88 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
90 \begin{memberdesc}{wfile} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 Contains the output stream for writing a response back to the client. |
|
13625
fdfd1049f36e
Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents:
10983
diff
changeset
|
92 Proper adherence to the HTTP protocol must be used when writing |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 to this stream. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
94 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
97 \class{BaseHTTPRequestHandler} has the following class variables: |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
99 \begin{memberdesc}{server_version} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 Specifies the server software version. You may want to override |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 this. |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 The format is multiple whitespace-separated strings, |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 where each string is of the form name[/version]. |
| 7684 | 104 For example, \code{'BaseHTTP/0.2'}. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
105 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
107 \begin{memberdesc}{sys_version} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 Contains the Python system version, in a form usable by the |
| 7684 | 109 \member{version_string} method and the \member{server_version} class |
| 110 variable. For example, \code{'Python/1.4'}. | |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
111 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
113 \begin{memberdesc}{error_message_format} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 Specifies a format string for building an error response to the |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 client. It uses parenthesized, keyed format specifiers, so the |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 format operand must be a dictionary. The \var{code} key should |
|
13625
fdfd1049f36e
Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents:
10983
diff
changeset
|
117 be an integer, specifying the numeric HTTP error code value. |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 \var{message} should be a string containing a (detailed) error |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 message of what occurred, and \var{explain} should be an |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 explanation of the error code number. Default \var{message} |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 and \var{explain} values can found in the \var{responses} |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 class variable. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
123 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
125 \begin{memberdesc}{protocol_version} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 This specifies the HTTP protocol version used in responses. |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 Typically, this should not be overridden. Defaults to |
| 7684 | 128 \code{'HTTP/1.0'}. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
129 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
131 \begin{memberdesc}{MessageClass} |
| 7684 | 132 Specifies a \class{rfc822.Message}-like class to parse HTTP |
| 133 headers. Typically, this is not overridden, and it defaults to | |
| 134 \class{mimetools.Message}. | |
| 135 \withsubitem{(in module mimetools)}{\ttindex{Message}} | |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
136 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
138 \begin{memberdesc}{responses} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 This variable contains a mapping of error code integers to two-element |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 tuples containing a short and long message. For example, |
| 7684 | 141 \code{\{\var{code}: (\var{shortmessage}, \var{longmessage})\}}. The |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 \var{shortmessage} is usually used as the \var{message} key in an |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 error response, and \var{longmessage} as the \var{explain} key |
| 7684 | 144 (see the \member{error_message_format} class variable). |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
145 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 |
| 7684 | 148 A \class{BaseHTTPRequestHandler} instance has the following methods: |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
150 \begin{methoddesc}{handle}{} |
| 7684 | 151 Overrides the superclass' \method{handle()} method to provide the |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 specific handler behavior. This method will parse and dispatch |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
153 the request to the appropriate \method{do_*()} method. |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
154 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
156 \begin{methoddesc}{send_error}{code\optional{, message}} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 Sends and logs a complete error reply to the client. The numeric |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 \var{code} specifies the HTTP error code, with \var{message} as |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
159 optional, more specific text. A complete set of headers is sent, |
| 7684 | 160 followed by text composed using the \member{error_message_format} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 class variable. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
162 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
164 \begin{methoddesc}{send_response}{code\optional{, message}} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 Sends a response header and logs the accepted request. The HTTP |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
166 response line is sent, followed by \emph{Server} and \emph{Date} |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 headers. The values for these two headers are picked up from the |
| 7684 | 168 \method{version_string()} and \method{date_time_string()} methods, |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 respectively. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
170 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
172 \begin{methoddesc}{send_header}{keyword, value} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 Writes a specific MIME header to the output stream. \var{keyword} |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 should specify the header keyword, with \var{value} specifying |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 its value. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
176 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
178 \begin{methoddesc}{end_headers}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 Sends a blank line, indicating the end of the MIME headers in |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 the response. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
181 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
183 \begin{methoddesc}{log_request}{\optional{code\optional{, size}}} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 Logs an accepted (successful) request. \var{code} should specify |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
185 the numeric HTTP code associated with the response. If a size of |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
186 the response is available, then it should be passed as the |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 \var{size} parameter. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
188 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
190 \begin{methoddesc}{log_error}{...} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 Logs an error when a request cannot be fulfilled. By default, |
| 7684 | 192 it passes the message to \method{log_message()}, so it takes the |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 same arguments (\var{format} and additional values). |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
194 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
196 \begin{methoddesc}{log_message}{format, ...} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 Logs an arbitrary message to \code{sys.stderr}. This is typically |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 overridden to create custom error logging mechanisms. The |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 \var{format} argument is a standard printf-style format string, |
| 7684 | 200 where the additional arguments to \method{log_message()} are applied |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 as inputs to the formatting. The client address and current date |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 and time are prefixed to every message logged. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
203 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
205 \begin{methoddesc}{version_string}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 Returns the server software's version string. This is a combination |
| 7684 | 207 of the \member{server_version} and \member{sys_version} class variables. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
208 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
210 \begin{methoddesc}{date_time_string}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 Returns the current date and time, formatted for a message header. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
212 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
214 \begin{methoddesc}{log_data_time_string}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 Returns the current date and time, formatted for logging. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
216 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
218 \begin{methoddesc}{address_string}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 Returns the client address, formatted for logging. A name lookup |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 is performed on the client's IP address. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
221 \end{methoddesc} |
|
10983
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
222 |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
223 |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
224 \begin{seealso} |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
225 \seemodule{CGIHTTPServer}{Extended request handler that supports CGI |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
226 scripts.} |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
227 |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
228 \seemodule{SimpleHTTPServer}{Basic request handler that limits response |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
229 to files actually under the document root.} |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
230 \end{seealso} |
