annotate Doc/lib/libbasehttp.tex @ 7277:bf4e790bd61a legacy-trunk

Remove all \bcode / \ecode cruft; this is no longer needed. See previous checkin of myformat.sty. Change "\renewcommand{\indexsubitem}{(...)}" to "\setindexsubitem{(...)}" everywhere. Some other minor nits that I happened to come across.
author Fred Drake <fdrake@acm.org>
date Fri, 13 Feb 1998 06:58:54 +0000
parents 48ab66874b11
children f0d33fdb3921
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6970
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 \section{Standard Module \sectcode{BaseHTTPServer}}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 \label{module-BaseHTTPServer}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 \stmodindex{BaseHTTPServer}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 \indexii{WWW}{server}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 \indexii{HTTP}{protocol}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 \index{URL}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 \index{httpd}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 7204
diff changeset
10 \setindexsubitem{(in module BaseHTTPServer)}
6970
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 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
13 (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
14 as a basis for building functioning web servers. See the
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 \code{SimpleHTTPServer} and \code{CGIHTTPServer} modules.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 \stmodindex{SimpleHTTPServer}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 \stmodindex{CGIHTTPServer}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 The first class, \code{HTTPServer}, is a \code{SocketServer.TCPServer}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 subclass. It creates and listens at the web socket, dispatching the
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 requests to a handler. Code to create and run the server looks like
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 this:
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 7204
diff changeset
24 \begin{verbatim}
6970
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 def run(server_class=BaseHTTPServer.HTTPServer,
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 server_address = ('', 8000)
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 httpd = server_class(server_address, handler_class)
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 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
30 \end{verbatim}
6970
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 %
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 The \code{HTTPServer} class builds on the \code{TCPServer} class by
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 storing the server address as instance
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 variables named \code{server_name} and \code{server_port}. The
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 server is accessible by the handler, typically through the handler's
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 \code{server} instance variable.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 The module's second class, \code{BaseHTTPRequestHandler}, is used
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 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
40 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
41 to handle each request method (e.g. GET or POST).
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 \code{BaseHTTPRequestHandler} provides a number of class and instance
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 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
44
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 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
46 method specific to the request type. The method name is constructed
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 from the request. For example, for the request \code{SPAM}, the
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 \code{do_SPAM} method will be called with no arguments. All of
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 the relevant information is stored into instance variables of the
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 handler.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 7204
diff changeset
52 \setindexsubitem{(BaseHTTPRequestHandler instance variable)}
6970
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 \code{BaseHTTPRequestHandler} has the following instance variables:
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
55
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 \begin{datadesc}{client_address}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 Contains a tuple of the form (host, port) referring to the client's
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 address.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 \begin{datadesc}{command}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 Contains the command (request type). For example, \code{"GET"}.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
64
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 \begin{datadesc}{path}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 Contains the request path.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
68
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 \begin{datadesc}{request_version}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 Contains the version string from the request. For example,
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 \code{"HTTP/1.0"}.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
73
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 \begin{datadesc}{headers}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 Holds an instance of the class specified by the \var{MessageClass}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 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
77 the HTTP request.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
79
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 \begin{datadesc}{rfile}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 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
82 input data.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
84
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 \begin{datadesc}{wfile}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 Contains the output stream for writing a response back to the client.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 Proper adherance to the HTTP protocol must be used when writing
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 to this stream.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
90
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 7204
diff changeset
91 \setindexsubitem{(BaseHTTPRequestHandler class variable)}
6970
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 \code{BaseHTTPRequestHandler} has the following class variables:
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
94
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 \begin{datadesc}{server_version}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 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
97 this.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 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
99 where each string is of the form name[/version].
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 For example, \code{"BaseHTTP/0.2"}.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 \begin{datadesc}{sys_version}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 Contains the Python system version, in a form usable by the
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 \code{version_string} method and the \code{server_version} class
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 variable. For example, \code{"Python/1.4"}.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
108
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 \begin{datadesc}{error_message_format}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 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
111 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
112 format operand must be a dictionary. The \var{code} key should
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 be an integer, specifing the numeric HTTP error code value.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
114 \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
115 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
116 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
117 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
118 class variable.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
120
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
121 \begin{datadesc}{protocol_version}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
122 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
123 Typically, this should not be overridden. Defaults to
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 \code{"HTTP/1.0"}.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
125 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
126
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
127 \begin{datadesc}{MessageClass}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
128 Specifies a Message-like class to parse HTTP headers. Typically,
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 this is not overridden, and it defaults to \code{mimetools.Message}.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
130 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
131
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 \begin{datadesc}{responses}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 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
134 tuples containing a short and long message. For example,
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 \code{\{code : (shortmessage, longmessage)\}}. The
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 \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
137 error response, and \var{longmessage} as the \var{explain} key
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 (see the \code{error_message_format} class variable).
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
139 \end{datadesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
140
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 7204
diff changeset
141 \setindexsubitem{(BaseHTTPRequestHandler method)}
6970
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
142
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
143 A \code{BaseHTTPRequestHandler} instance has the following methods:
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
144
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
145 \begin{funcdesc}{handle}{}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
146 Overrides the superclass' \code{handle} method to provide the
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
147 specific handler behavior. This method will parse and dispatch
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
148 the request to the appropriate \code{do_}* method.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
149 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
150
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
151 \begin{funcdesc}{send_error}{code\optional{\, message}}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
152 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
153 \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
154 optional, more specific text. A complete set of headers is sent,
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 followed by text composed using the \code{error_message_format}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
156 class variable.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
157 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
158
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
159 \begin{funcdesc}{send_response}{code\optional{\, message}}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 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
161 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
162 headers. The values for these two headers are picked up from the
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
163 \code{version_string()} and \code{date_time_string()} methods,
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 respectively.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
165 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
166
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
167 \begin{funcdesc}{send_header}{keyword\, value}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 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
169 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
170 its value.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
171 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
172
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
173 \begin{funcdesc}{end_headers}{}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
174 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
175 the response.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
177
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
178 \begin{funcdesc}{log_request}{\optional{code\optional{\, size}}}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
179 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
180 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
181 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
182 \var{size} parameter.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
184
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
185 \begin{funcdesc}{log_error}{...}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
186 Logs an error when a request cannot be fulfilled. By default,
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
187 it passes the message to \code{log_message}, so it takes the
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
188 same arguments (\var{format} and additional values).
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
189 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
190
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
191 \begin{funcdesc}{log_message}{format, ...}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
192 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
193 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
194 \var{format} argument is a standard printf-style format string,
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
195 where the additional arguments to \code{log_message} are applied
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
196 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
197 and time are prefixed to every message logged.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
198 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
199
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
200 \begin{funcdesc}{version_string}{}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
201 Returns the server software's version string. This is a combination
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
202 of the \var{server_version} and \var{sys_version} class variables.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
203 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
204
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
205 \begin{funcdesc}{date_time_string}{}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
206 Returns the current date and time, formatted for a message header.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
208
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
209 \begin{funcdesc}{log_data_time_string}{}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
210 Returns the current date and time, formatted for logging.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
211 \end{funcdesc}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
212
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
213 \begin{funcdesc}{address_string}{}
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
214 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
215 is performed on the client's IP address.
e5aff41036f3 Added Greg Stein's docs for BaseHTTPServer.py.
Guido van Rossum <guido@python.org>
parents:
diff changeset
216 \end{funcdesc}