Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{BaseHTTPServer} --- |
Fred Drake | 4d3714b | 2000-10-10 16:56:41 +0000 | [diff] [blame] | 2 | Basic HTTP server} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | |
Fred Drake | 4d3714b | 2000-10-10 16:56:41 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{BaseHTTPServer} |
Fred Drake | 72d157e | 1998-08-06 21:23:17 +0000 | [diff] [blame] | 5 | \modulesynopsis{Basic HTTP server (base class for |
Fred Drake | 4d3714b | 2000-10-10 16:56:41 +0000 | [diff] [blame] | 6 | \class{SimpleHTTPServer} and \class{CGIHTTPServer}).} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 7 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 8 | |
| 9 | \indexii{WWW}{server} |
| 10 | \indexii{HTTP}{protocol} |
| 11 | \index{URL} |
| 12 | \index{httpd} |
| 13 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 14 | This module defines two classes for implementing HTTP servers |
Fred Drake | 8ee679f | 2001-07-14 02:50:55 +0000 | [diff] [blame] | 15 | (Web servers). Usually, this module isn't used directly, but is used |
| 16 | as a basis for building functioning Web servers. See the |
Fred Drake | c46864e | 1999-06-14 19:49:50 +0000 | [diff] [blame] | 17 | \module{SimpleHTTPServer}\refstmodindex{SimpleHTTPServer} and |
| 18 | \refmodule{CGIHTTPServer}\refstmodindex{CGIHTTPServer} modules. |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 19 | |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 20 | The first class, \class{HTTPServer}, is a |
Fred Drake | 8ee679f | 2001-07-14 02:50:55 +0000 | [diff] [blame] | 21 | \class{SocketServer.TCPServer} subclass. It creates and listens at the |
| 22 | HTTP socket, dispatching the requests to a handler. Code to create and |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 23 | run the server looks like this: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 24 | |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 25 | \begin{verbatim} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 26 | def run(server_class=BaseHTTPServer.HTTPServer, |
| 27 | handler_class=BaseHTTPServer.BaseHTTPRequestHandler): |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 28 | server_address = ('', 8000) |
| 29 | httpd = server_class(server_address, handler_class) |
| 30 | httpd.serve_forever() |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 31 | \end{verbatim} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 32 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 33 | \begin{classdesc}{HTTPServer}{server_address, RequestHandlerClass} |
| 34 | This class builds on the \class{TCPServer} class by |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 35 | storing the server address as instance |
| 36 | variables named \member{server_name} and \member{server_port}. The |
| 37 | server is accessible by the handler, typically through the handler's |
| 38 | \member{server} instance variable. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 39 | \end{classdesc} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 40 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 41 | \begin{classdesc}{BaseHTTPRequestHandler}{request, client_address, server} |
| 42 | This class is used |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 43 | to handle the HTTP requests that arrive at the server. By itself, |
| 44 | it cannot respond to any actual HTTP requests; it must be subclassed |
| 45 | to handle each request method (e.g. GET or POST). |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 46 | \class{BaseHTTPRequestHandler} provides a number of class and instance |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 47 | variables, and methods for use by subclasses. |
| 48 | |
| 49 | The handler will parse the request and the headers, then call a |
| 50 | method specific to the request type. The method name is constructed |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 51 | from the request. For example, for the request method \samp{SPAM}, the |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 52 | \method{do_SPAM()} method will be called with no arguments. All of |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 53 | the relevant information is stored in instance variables of the |
| 54 | handler. Subclasses should not need to override or extend the |
| 55 | \method{__init__()} method. |
| 56 | \end{classdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 57 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 58 | |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 59 | \class{BaseHTTPRequestHandler} has the following instance variables: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 60 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 61 | \begin{memberdesc}{client_address} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 62 | Contains a tuple of the form \code{(\var{host}, \var{port})} referring |
| 63 | to the client's address. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 64 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 65 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 66 | \begin{memberdesc}{command} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 67 | Contains the command (request type). For example, \code{'GET'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 68 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 69 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 70 | \begin{memberdesc}{path} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 71 | Contains the request path. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 72 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 73 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 74 | \begin{memberdesc}{request_version} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 75 | Contains the version string from the request. For example, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 76 | \code{'HTTP/1.0'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 77 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 78 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 79 | \begin{memberdesc}{headers} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 80 | Holds an instance of the class specified by the \member{MessageClass} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 81 | class variable. This instance parses and manages the headers in |
| 82 | the HTTP request. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 83 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 84 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 85 | \begin{memberdesc}{rfile} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 86 | Contains an input stream, positioned at the start of the optional |
| 87 | input data. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 88 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 89 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 90 | \begin{memberdesc}{wfile} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 91 | Contains the output stream for writing a response back to the client. |
Thomas Wouters | f831663 | 2000-07-16 19:01:10 +0000 | [diff] [blame] | 92 | Proper adherence to the HTTP protocol must be used when writing |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 93 | to this stream. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 94 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 95 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 96 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 97 | \class{BaseHTTPRequestHandler} has the following class variables: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 98 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 99 | \begin{memberdesc}{server_version} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 100 | Specifies the server software version. You may want to override |
| 101 | this. |
| 102 | The format is multiple whitespace-separated strings, |
| 103 | where each string is of the form name[/version]. |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 104 | For example, \code{'BaseHTTP/0.2'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 105 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 106 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 107 | \begin{memberdesc}{sys_version} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 108 | Contains the Python system version, in a form usable by the |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 109 | \member{version_string} method and the \member{server_version} class |
| 110 | variable. For example, \code{'Python/1.4'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 111 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 112 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 113 | \begin{memberdesc}{error_message_format} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 114 | Specifies a format string for building an error response to the |
| 115 | client. It uses parenthesized, keyed format specifiers, so the |
| 116 | format operand must be a dictionary. The \var{code} key should |
Thomas Wouters | f831663 | 2000-07-16 19:01:10 +0000 | [diff] [blame] | 117 | be an integer, specifying the numeric HTTP error code value. |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 118 | \var{message} should be a string containing a (detailed) error |
| 119 | message of what occurred, and \var{explain} should be an |
| 120 | explanation of the error code number. Default \var{message} |
| 121 | and \var{explain} values can found in the \var{responses} |
| 122 | class variable. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 123 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 124 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 125 | \begin{memberdesc}{protocol_version} |
Martin v. Löwis | 587c98c | 2002-03-17 18:37:22 +0000 | [diff] [blame] | 126 | This specifies the HTTP protocol version used in responses. If set |
| 127 | to \code{'HTTP/1.1'}, the server will permit HTTP persistent |
| 128 | connections; however, your server \emph{must} then include an |
| 129 | accurate \code{Content-Length} header (using \method{send_header()}) |
| 130 | in all of its responses to clients. For backwards compatibility, |
| 131 | the setting defaults to \code{'HTTP/1.0'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 132 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 133 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 134 | \begin{memberdesc}{MessageClass} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 135 | Specifies a \class{rfc822.Message}-like class to parse HTTP |
| 136 | headers. Typically, this is not overridden, and it defaults to |
| 137 | \class{mimetools.Message}. |
| 138 | \withsubitem{(in module mimetools)}{\ttindex{Message}} |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 139 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 140 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 141 | \begin{memberdesc}{responses} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 142 | This variable contains a mapping of error code integers to two-element |
| 143 | tuples containing a short and long message. For example, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 144 | \code{\{\var{code}: (\var{shortmessage}, \var{longmessage})\}}. The |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 145 | \var{shortmessage} is usually used as the \var{message} key in an |
| 146 | error response, and \var{longmessage} as the \var{explain} key |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 147 | (see the \member{error_message_format} class variable). |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 148 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 149 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 150 | |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 151 | A \class{BaseHTTPRequestHandler} instance has the following methods: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 152 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 153 | \begin{methoddesc}{handle}{} |
Martin v. Löwis | 587c98c | 2002-03-17 18:37:22 +0000 | [diff] [blame] | 154 | Calls \method{handle_one_request()} once (or, if persistent connections |
| 155 | are enabled, multiple times) to handle incoming HTTP requests. |
| 156 | You should never need to override it; instead, implement appropriate |
| 157 | \method{do_*()} methods. |
| 158 | \end{methoddesc} |
| 159 | |
| 160 | \begin{methoddesc}{handle_one_request}{} |
| 161 | This method will parse and dispatch |
| 162 | the request to the appropriate \method{do_*()} method. You should |
| 163 | never need to override it. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 164 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 165 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 166 | \begin{methoddesc}{send_error}{code\optional{, message}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 167 | Sends and logs a complete error reply to the client. The numeric |
| 168 | \var{code} specifies the HTTP error code, with \var{message} as |
| 169 | optional, more specific text. A complete set of headers is sent, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 170 | followed by text composed using the \member{error_message_format} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 171 | class variable. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 172 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 173 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 174 | \begin{methoddesc}{send_response}{code\optional{, message}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 175 | Sends a response header and logs the accepted request. The HTTP |
| 176 | response line is sent, followed by \emph{Server} and \emph{Date} |
| 177 | headers. The values for these two headers are picked up from the |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 178 | \method{version_string()} and \method{date_time_string()} methods, |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 179 | respectively. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 180 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 181 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 182 | \begin{methoddesc}{send_header}{keyword, value} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 183 | Writes a specific MIME header to the output stream. \var{keyword} |
| 184 | should specify the header keyword, with \var{value} specifying |
| 185 | its value. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 186 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 187 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 188 | \begin{methoddesc}{end_headers}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 189 | Sends a blank line, indicating the end of the MIME headers in |
| 190 | the response. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 191 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 192 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 193 | \begin{methoddesc}{log_request}{\optional{code\optional{, size}}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 194 | Logs an accepted (successful) request. \var{code} should specify |
| 195 | the numeric HTTP code associated with the response. If a size of |
| 196 | the response is available, then it should be passed as the |
| 197 | \var{size} parameter. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 198 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 199 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 200 | \begin{methoddesc}{log_error}{...} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 201 | Logs an error when a request cannot be fulfilled. By default, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 202 | it passes the message to \method{log_message()}, so it takes the |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 203 | same arguments (\var{format} and additional values). |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 204 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 205 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 206 | \begin{methoddesc}{log_message}{format, ...} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 207 | Logs an arbitrary message to \code{sys.stderr}. This is typically |
| 208 | overridden to create custom error logging mechanisms. The |
| 209 | \var{format} argument is a standard printf-style format string, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 210 | where the additional arguments to \method{log_message()} are applied |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 211 | as inputs to the formatting. The client address and current date |
| 212 | and time are prefixed to every message logged. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 213 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 214 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 215 | \begin{methoddesc}{version_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 216 | Returns the server software's version string. This is a combination |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 217 | of the \member{server_version} and \member{sys_version} class variables. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 218 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 219 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 220 | \begin{methoddesc}{date_time_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 221 | Returns the current date and time, formatted for a message header. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 222 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 223 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 224 | \begin{methoddesc}{log_data_time_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 225 | Returns the current date and time, formatted for logging. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 226 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 227 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 228 | \begin{methoddesc}{address_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 229 | Returns the client address, formatted for logging. A name lookup |
| 230 | is performed on the client's IP address. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 231 | \end{methoddesc} |
Fred Drake | c46864e | 1999-06-14 19:49:50 +0000 | [diff] [blame] | 232 | |
| 233 | |
| 234 | \begin{seealso} |
| 235 | \seemodule{CGIHTTPServer}{Extended request handler that supports CGI |
| 236 | scripts.} |
| 237 | |
| 238 | \seemodule{SimpleHTTPServer}{Basic request handler that limits response |
| 239 | to files actually under the document root.} |
| 240 | \end{seealso} |