Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
59a27f1d
Commit
59a27f1d
authored
Aug 07, 2004
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various minor edits
parent
4cbe95cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
Doc/lib/libsimplehttp.tex
Doc/lib/libsimplehttp.tex
+15
-14
No files found.
Doc/lib/libsimplehttp.tex
View file @
59a27f1d
...
...
@@ -8,19 +8,18 @@
The
\module
{
SimpleHTTPServer
}
module defines a request-handler class,
interface
compatible with
\class
{
BaseHTTPServer.BaseHTTPRequestHandler
}
which
serves files only from a base directory.
interface
-compatible with
\class
{
BaseHTTPServer.BaseHTTPRequestHandler
}
,
that
serves files only from a base directory.
The
\module
{
SimpleHTTPServer
}
module defines the following class:
\begin{classdesc}
{
SimpleHTTPRequestHandler
}{
request, client
_
address, server
}
This class is used
, to serve files from
current directory and below,
This class is used
to serve files from the
current directory and below,
directly mapping the directory structure to HTTP requests.
A lot of the work is done by the base class
\class
{
BaseHTTPServer.BaseHTTPRequestHandler
}
, such as parsing the
request. This class implements the
\function
{
do
_
GET()
}
and
\function
{
do
_
HEAD()
}
functions.
A lot of the work, such as parsing the request, is done by the base
class
\class
{
BaseHTTPServer.BaseHTTPRequestHandler
}
. This class
implements the
\function
{
do
_
GET()
}
and
\function
{
do
_
HEAD()
}
functions.
\end{classdesc}
The
\class
{
SimpleHTTPRequestHandler
}
defines the following member
...
...
@@ -32,7 +31,7 @@ is defined in the module.
\end{memberdesc}
\begin{memberdesc}
{
extensions
_
map
}
A dictionary mapping suffixes into MIME types.
D
efault is signified
A dictionary mapping suffixes into MIME types.
The d
efault is signified
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.
...
...
@@ -43,7 +42,7 @@ The \class{SimpleHTTPRequestHandler} defines the following methods:
\begin{methoddesc}
{
do
_
HEAD
}{}
This method serves the
\code
{
'HEAD'
}
request type: it sends the
headers it would send for the equivalent
\code
{
GET
}
request. See the
\method
{
do
_
GET()
}
method for more complete explanation of the possible
\method
{
do
_
GET()
}
method for
a
more complete explanation of the possible
headers.
\end{methoddesc}
...
...
@@ -61,13 +60,15 @@ 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
error. Otherwise, the content type is guessed by calling the
\method
{
guess
_
type()
}
method, which in turn uses 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. If the file's MIME type starts with
\code
{
text/
}
the file is
opened in text mode; otherwise binary mode is used.
A
\code
{
'Content-type:'
}
header with the guessed content type is
output, followed by a blank line signifying the end of the headers,
and then the contents of the file are output. 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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment