summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libsimplehttp.tex
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2004-08-07 19:06:48 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2004-08-07 19:06:48 (GMT)
commit4cbe95cdd1353a670cab0c652b030d36ee36feb6 (patch)
tree9890ecca8402f0a3a73314e814d5f6a3f96c3bc1 /Doc/lib/libsimplehttp.tex
parentb839c1f33f842720e9592c4ef598688bed94266f (diff)
downloadcpython-4cbe95cdd1353a670cab0c652b030d36ee36feb6.zip
cpython-4cbe95cdd1353a670cab0c652b030d36ee36feb6.tar.gz
cpython-4cbe95cdd1353a670cab0c652b030d36ee36feb6.tar.bz2
[Bug #866222] Update docs to match the module
Diffstat (limited to 'Doc/lib/libsimplehttp.tex')
-rw-r--r--Doc/lib/libsimplehttp.tex22
1 files changed, 15 insertions, 7 deletions
diff --git a/Doc/lib/libsimplehttp.tex b/Doc/lib/libsimplehttp.tex
index 6745298..e409f91 100644
--- a/Doc/lib/libsimplehttp.tex
+++ b/Doc/lib/libsimplehttp.tex
@@ -33,7 +33,7 @@ is defined in the module.
\begin{memberdesc}{extensions_map}
A dictionary mapping suffixes into MIME types. Default is signified
-by an empty string, and is considered to be \code{text/plain}.
+by an empty string, and is considered to be \code{application/octet-stream}.
The mapping is used case-insensitively, and so should contain only
lower-cased keys.
\end{memberdesc}
@@ -51,15 +51,23 @@ headers.
The request is mapped to a local file by interpreting the request as
a path relative to the current working directory.
-If the request was mapped to a directory, a \code{403} respond is output,
-followed by the explanation \code{'Directory listing not supported'}.
-Any \exception{IOError} exception in opening the requested file, is mapped
-to a \code{404}, \code{'File not found'} error. Otherwise, the content
-type is guessed using the \var{extensions_map} variable.
+If the request was mapped to a directory, the directory is checked for
+a file named \code{index.html} or \code{index.htm} (in that order).
+If found, the file's contents are returned; otherwise a directory
+listing is generated by calling the \method{list_directory()} method.
+This method uses \function{os.listdir()} to scan the directory, and
+returns a \code{404} error response if the \function{listdir()} fails.
+
+If the request was mapped to a file, it is opened and the contents are
+returned. Any \exception{IOError} exception in opening the requested
+file is mapped to a \code{404}, \code{'File not found'}
+error. Otherwise, the content type is guessed using the
+\var{extensions_map} variable.
A \code{'Content-type:'} with the guessed content type is output, and
then a blank line, signifying end of headers, and then the contents of
-the file. The file is always opened in binary mode.
+the file. If the file's MIME type starts with \code{text/} the file is
+opened in text mode; otherwise binary mode is used.
For example usage, see the implementation of the \function{test()}
function.