diff options
author | Pierre Quentel <pierre.quentel@gmail.com> | 2017-04-02 10:26:12 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-04-02 10:26:12 (GMT) |
commit | 351adda54bed3afbbf6db7725699679e68722d7d (patch) | |
tree | cde5d5563d5fc31730378a164ea0b73d0d67ff35 /Doc/library/http.server.rst | |
parent | efbd4ea65dbb9f87b1afeec6a760802756badee5 (diff) | |
download | cpython-351adda54bed3afbbf6db7725699679e68722d7d.zip cpython-351adda54bed3afbbf6db7725699679e68722d7d.tar.gz cpython-351adda54bed3afbbf6db7725699679e68722d7d.tar.bz2 |
bpo-29654 : Support If-Modified-Since HTTP header (browser cache) (#298)
Return 304 response if file was not modified.
Diffstat (limited to 'Doc/library/http.server.rst')
-rw-r--r-- | Doc/library/http.server.rst | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst index fb5c1df..ee1c37c 100644 --- a/Doc/library/http.server.rst +++ b/Doc/library/http.server.rst @@ -343,11 +343,13 @@ of which this module provides three different variants: :func:`os.listdir` to scan the directory, and returns a ``404`` error response if the :func:`~os.listdir` fails. - If the request was mapped to a file, it is opened and the contents are - returned. Any :exc:`OSError` exception in opening the requested file is - mapped to a ``404``, ``'File not found'`` error. Otherwise, the content + If the request was mapped to a file, it is opened. Any :exc:`OSError` + exception in opening the requested file is mapped to a ``404``, + ``'File not found'`` error. If there was a ``'If-Modified-Since'`` + header in the request, and the file was not modified after this time, + a ``304``, ``'Not Modified'`` response is sent. Otherwise, the content type is guessed by calling the :meth:`guess_type` method, which in turn - uses the *extensions_map* variable. + uses the *extensions_map* variable, and the file contents are returned. A ``'Content-type:'`` header with the guessed content type is output, followed by a ``'Content-Length:'`` header with the file's size and a @@ -360,6 +362,8 @@ of which this module provides three different variants: For example usage, see the implementation of the :func:`test` function invocation in the :mod:`http.server` module. + .. versionchanged:: 3.7 + Support of the ``'If-Modified-Since'`` header. The :class:`SimpleHTTPRequestHandler` class can be used in the following manner in order to create a very basic webserver serving files relative to |