Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libbasehttp.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 | 39f242bf4622 |
| children | dd49f29d9879 |
| rev | line source |
|---|---|
| 8918 | 1 \section{\module{BaseHTTPServer} --- |
| 2 Basic HTTP server.} | |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7875
diff
changeset
|
3 \declaremodule{standard}{BaseHTTPServer} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7875
diff
changeset
|
4 |
| 8855 | 5 \modulesynopsis{Basic HTTP server (base class for |
| 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 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 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
|
16 (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
|
17 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
|
18 \module{SimpleHTTPServer}\refstmodindex{SimpleHTTPServer} and |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
19 \refmodule{CGIHTTPServer}\refstmodindex{CGIHTTPServer} modules. |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 |
| 7684 | 21 The first class, \class{HTTPServer}, is a |
| 22 \class{SocketServer.TCPServer} subclass. It creates and listens at the | |
| 23 web socket, dispatching the requests to a handler. Code to create and | |
| 24 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
|
25 |
|
7277
bf4e790bd61a
Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents:
7204
diff
changeset
|
26 \begin{verbatim} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 def run(server_class=BaseHTTPServer.HTTPServer, |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 handler_class=BaseHTTPServer.BaseHTTPRequestHandler): |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
29 server_address = ('', 8000) |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
30 httpd = server_class(server_address, handler_class) |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
31 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
|
32 \end{verbatim} |
| 7684 | 33 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
34 \begin{classdesc}{HTTPServer}{server_address, RequestHandlerClass} |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
35 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
|
36 storing the server address as instance |
| 7684 | 37 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
|
38 server is accessible by the handler, typically through the handler's |
| 7684 | 39 \member{server} instance variable. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
40 \end{classdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
42 \begin{classdesc}{BaseHTTPRequestHandler}{request, client_address, server} |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
43 This class is used |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 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
|
45 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
|
46 to handle each request method (e.g. GET or POST). |
| 7684 | 47 \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
|
48 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
|
49 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 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
|
51 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
|
52 from the request. For example, for the request method \samp{SPAM}, the |
| 7684 | 53 \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
|
54 the relevant information is stored in instance variables of the |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
55 handler. Subclasses should not need to override or extend the |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
56 \method{__init__()} method. |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
57 \end{classdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 |
| 7684 | 60 \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
|
61 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
62 \begin{memberdesc}{client_address} |
| 7684 | 63 Contains a tuple of the form \code{(\var{host}, \var{port})} referring |
| 64 to the client's address. | |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
65 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
67 \begin{memberdesc}{command} |
| 7684 | 68 Contains the command (request type). For example, \code{'GET'}. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
69 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
71 \begin{memberdesc}{path} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 Contains the request path. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
73 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
75 \begin{memberdesc}{request_version} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 Contains the version string from the request. For example, |
| 7684 | 77 \code{'HTTP/1.0'}. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
78 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
80 \begin{memberdesc}{headers} |
| 7684 | 81 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
|
82 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
|
83 the HTTP request. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
84 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
86 \begin{memberdesc}{rfile} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 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
|
88 input data. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
89 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
91 \begin{memberdesc}{wfile} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 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
|
93 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
|
94 to this stream. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
95 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
98 \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
|
99 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
100 \begin{memberdesc}{server_version} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 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
|
102 this. |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 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
|
104 where each string is of the form name[/version]. |
| 7684 | 105 For example, \code{'BaseHTTP/0.2'}. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
106 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
108 \begin{memberdesc}{sys_version} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 Contains the Python system version, in a form usable by the |
| 7684 | 110 \member{version_string} method and the \member{server_version} class |
| 111 variable. For example, \code{'Python/1.4'}. | |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
112 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
114 \begin{memberdesc}{error_message_format} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 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
|
119 \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
|
120 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
|
121 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
|
122 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
|
123 class variable. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
124 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
126 \begin{memberdesc}{protocol_version} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 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
|
128 Typically, this should not be overridden. Defaults to |
| 7684 | 129 \code{'HTTP/1.0'}. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
130 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
132 \begin{memberdesc}{MessageClass} |
| 7684 | 133 Specifies a \class{rfc822.Message}-like class to parse HTTP |
| 134 headers. Typically, this is not overridden, and it defaults to | |
| 135 \class{mimetools.Message}. | |
| 136 \withsubitem{(in module mimetools)}{\ttindex{Message}} | |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
137 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
139 \begin{memberdesc}{responses} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 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
|
141 tuples containing a short and long message. For example, |
| 7684 | 142 \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
|
143 \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
|
144 error response, and \var{longmessage} as the \var{explain} key |
| 7684 | 145 (see the \member{error_message_format} class variable). |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
146 \end{memberdesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 |
|
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 |
| 7684 | 149 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
|
150 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
151 \begin{methoddesc}{handle}{} |
| 7684 | 152 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
|
153 specific handler behavior. This method will parse and dispatch |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
154 the request to the appropriate \method{do_*()} method. |
|
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
155 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
157 \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
|
158 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
|
159 \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
|
160 optional, more specific text. A complete set of headers is sent, |
| 7684 | 161 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
|
162 class variable. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
163 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
165 \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
|
166 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
|
167 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
|
168 headers. The values for these two headers are picked up from the |
| 7684 | 169 \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
|
170 respectively. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
171 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
173 \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
|
174 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
|
175 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
|
176 its value. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
177 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
179 \begin{methoddesc}{end_headers}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 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
|
181 the response. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
182 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
184 \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
|
185 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
|
186 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
|
187 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
|
188 \var{size} parameter. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
189 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
190 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
191 \begin{methoddesc}{log_error}{...} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 Logs an error when a request cannot be fulfilled. By default, |
| 7684 | 193 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
|
194 same arguments (\var{format} and additional values). |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
195 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
197 \begin{methoddesc}{log_message}{format, ...} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 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
|
199 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
|
200 \var{format} argument is a standard printf-style format string, |
| 7684 | 201 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
|
202 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
|
203 and time are prefixed to every message logged. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
204 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
206 \begin{methoddesc}{version_string}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 Returns the server software's version string. This is a combination |
| 7684 | 208 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
|
209 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
211 \begin{methoddesc}{date_time_string}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 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
|
213 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
215 \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
|
216 Returns the current date and time, formatted for logging. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
217 \end{methoddesc} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
219 \begin{methoddesc}{address_string}{} |
|
6970
e5aff41036f3
Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 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
|
221 is performed on the client's IP address. |
|
7875
8f425f8f4be2
Remove obsolete \setindexsubitem macros.
Fred Drake <fdrake@acm.org>
parents:
7712
diff
changeset
|
222 \end{methoddesc} |
|
10983
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 |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
225 \begin{seealso} |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
226 \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
|
227 scripts.} |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
228 |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
229 \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
|
230 to files actually under the document root.} |
|
39f242bf4622
Misc. changes related to the new sections.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
231 \end{seealso} |
