Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4cbe95c

Browse files
committed
[Bug #866222] Update docs to match the module
1 parent b839c1f commit 4cbe95c

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

Doc/lib/libsimplehttp.tex

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ \section{\module{SimpleHTTPServer} ---
3333

3434
\begin{memberdesc}{extensions_map}
3535
A dictionary mapping suffixes into MIME types. Default is signified
36-
by an empty string, and is considered to be \code{text/plain}.
36+
by an empty string, and is considered to be \code{application/octet-stream}.
3737
The mapping is used case-insensitively, and so should contain only
3838
lower-cased keys.
3939
\end{memberdesc}
@@ -51,15 +51,23 @@ \section{\module{SimpleHTTPServer} ---
5151
The request is mapped to a local file by interpreting the request as
5252
a path relative to the current working directory.
5353

54-
If the request was mapped to a directory, a \code{403} respond is output,
55-
followed by the explanation \code{'Directory listing not supported'}.
56-
Any \exception{IOError} exception in opening the requested file, is mapped
57-
to a \code{404}, \code{'File not found'} error. Otherwise, the content
58-
type is guessed using the \var{extensions_map} variable.
54+
If the request was mapped to a directory, the directory is checked for
55+
a file named \code{index.html} or \code{index.htm} (in that order).
56+
If found, the file's contents are returned; otherwise a directory
57+
listing is generated by calling the \method{list_directory()} method.
58+
This method uses \function{os.listdir()} to scan the directory, and
59+
returns a \code{404} error response if the \function{listdir()} fails.
60+
61+
If the request was mapped to a file, it is opened and the contents are
62+
returned. Any \exception{IOError} exception in opening the requested
63+
file is mapped to a \code{404}, \code{'File not found'}
64+
error. Otherwise, the content type is guessed using the
65+
\var{extensions_map} variable.
5966

6067
A \code{'Content-type:'} with the guessed content type is output, and
6168
then a blank line, signifying end of headers, and then the contents of
62-
the file. The file is always opened in binary mode.
69+
the file. If the file's MIME type starts with \code{text/} the file is
70+
opened in text mode; otherwise binary mode is used.
6371

6472
For example usage, see the implementation of the \function{test()}
6573
function.

0 commit comments

Comments
 (0)