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} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 126 | This specifies the HTTP protocol version used in responses. |
| 127 | Typically, this should not be overridden. Defaults to |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 128 | \code{'HTTP/1.0'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 129 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 130 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 131 | \begin{memberdesc}{MessageClass} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 132 | Specifies a \class{rfc822.Message}-like class to parse HTTP |
| 133 | headers. Typically, this is not overridden, and it defaults to |
| 134 | \class{mimetools.Message}. |
| 135 | \withsubitem{(in module mimetools)}{\ttindex{Message}} |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 136 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 137 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 138 | \begin{memberdesc}{responses} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 139 | This variable contains a mapping of error code integers to two-element |
| 140 | tuples containing a short and long message. For example, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 141 | \code{\{\var{code}: (\var{shortmessage}, \var{longmessage})\}}. The |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 142 | \var{shortmessage} is usually used as the \var{message} key in an |
| 143 | error response, and \var{longmessage} as the \var{explain} key |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 144 | (see the \member{error_message_format} class variable). |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 145 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 146 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 147 | |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 148 | A \class{BaseHTTPRequestHandler} instance has the following methods: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 149 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 150 | \begin{methoddesc}{handle}{} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 151 | Overrides the superclass' \method{handle()} method to provide the |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 152 | specific handler behavior. This method will parse and dispatch |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 153 | the request to the appropriate \method{do_*()} method. |
| 154 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 155 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 156 | \begin{methoddesc}{send_error}{code\optional{, message}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 157 | Sends and logs a complete error reply to the client. The numeric |
| 158 | \var{code} specifies the HTTP error code, with \var{message} as |
| 159 | optional, more specific text. A complete set of headers is sent, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 160 | followed by text composed using the \member{error_message_format} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 161 | class variable. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 162 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 163 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 164 | \begin{methoddesc}{send_response}{code\optional{, message}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 165 | Sends a response header and logs the accepted request. The HTTP |
| 166 | response line is sent, followed by \emph{Server} and \emph{Date} |
| 167 | headers. The values for these two headers are picked up from the |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 168 | \method{version_string()} and \method{date_time_string()} methods, |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 169 | respectively. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 170 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 171 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 172 | \begin{methoddesc}{send_header}{keyword, value} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 173 | Writes a specific MIME header to the output stream. \var{keyword} |
| 174 | should specify the header keyword, with \var{value} specifying |
| 175 | its value. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 176 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 177 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 178 | \begin{methoddesc}{end_headers}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 179 | Sends a blank line, indicating the end of the MIME headers in |
| 180 | the response. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 181 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 182 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 183 | \begin{methoddesc}{log_request}{\optional{code\optional{, size}}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 184 | Logs an accepted (successful) request. \var{code} should specify |
| 185 | the numeric HTTP code associated with the response. If a size of |
| 186 | the response is available, then it should be passed as the |
| 187 | \var{size} parameter. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 188 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 189 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 190 | \begin{methoddesc}{log_error}{...} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 191 | Logs an error when a request cannot be fulfilled. By default, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 192 | 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] | 193 | same arguments (\var{format} and additional values). |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 194 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 195 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 196 | \begin{methoddesc}{log_message}{format, ...} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 197 | Logs an arbitrary message to \code{sys.stderr}. This is typically |
| 198 | overridden to create custom error logging mechanisms. The |
| 199 | \var{format} argument is a standard printf-style format string, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 200 | where the additional arguments to \method{log_message()} are applied |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 201 | as inputs to the formatting. The client address and current date |
| 202 | and time are prefixed to every message logged. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 203 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 204 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 205 | \begin{methoddesc}{version_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 206 | Returns the server software's version string. This is a combination |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 207 | of the \member{server_version} and \member{sys_version} class variables. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 208 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 209 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 210 | \begin{methoddesc}{date_time_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 211 | Returns the current date and time, formatted for a message header. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 212 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 213 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 214 | \begin{methoddesc}{log_data_time_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 215 | Returns the current date and time, formatted for logging. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 216 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 217 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 218 | \begin{methoddesc}{address_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 219 | Returns the client address, formatted for logging. A name lookup |
| 220 | is performed on the client's IP address. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 221 | \end{methoddesc} |
Fred Drake | c46864e | 1999-06-14 19:49:50 +0000 | [diff] [blame] | 222 | |
| 223 | |
| 224 | \begin{seealso} |
| 225 | \seemodule{CGIHTTPServer}{Extended request handler that supports CGI |
| 226 | scripts.} |
| 227 | |
| 228 | \seemodule{SimpleHTTPServer}{Basic request handler that limits response |
| 229 | to files actually under the document root.} |
| 230 | \end{seealso} |