Skip to content

Commit 64c3070

Browse files
committed
Update docs
1 parent 75fff2b commit 64c3070

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

Doc/library/http.server.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ The :class:`HTTPServer` and :class:`ThreadingHTTPServer` must be given
5555
a *RequestHandlerClass* on instantiation, of which this module
5656
provides three different variants:
5757

58+
.. class:: HTTPSServer(server_address, RequestHandlerClass, \
59+
bind_and_activate=True, *, certfile, keyfile=None, \
60+
password=None, alpn_protocols=None)
61+
62+
This class is a :class:`HTTPServer` subclass with a wrapped socket using the
63+
:mod:`ssl`, if the :mod:`ssl` module is not available the class will not
64+
initialize. The *certfile* argument is required and is the path to the SSL
65+
certificate chain file. The *keyfile* is the path to its private key. But
66+
private keys are often protected and wrapped with PKCS #8, so we provide
67+
*password* argument for that case.
68+
69+
.. versionadded:: 3.14
70+
71+
.. class:: ThreadingHTTPSServer(server_address, RequestHandlerClass, \
72+
bind_and_activate=True, *, certfile, keyfile=None, \
73+
password=None, alpn_protocols=None)
74+
75+
This class is identical to :class:`HTTPSServer` but uses threads to handle
76+
requests by using the :class:`~socketserver.ThreadingMixIn`. This is
77+
analogue of :class:`ThreadingHTTPServer` class only using
78+
:class:`HTTPSServer`.
79+
80+
.. versionadded:: 3.14
81+
5882
.. class:: BaseHTTPRequestHandler(request, client_address, server)
5983

6084
This class is used to handle the HTTP requests that arrive at the server. By
@@ -462,6 +486,17 @@ following command runs an HTTP/1.1 conformant server::
462486
.. versionchanged:: 3.11
463487
Added the ``--protocol`` option.
464488

489+
The server can also support TLS encryption. The options ``--tls-cert`` and
490+
``--tls-key`` allow specifying a TLS certificate chain and private key for
491+
secure HTTPS connections. And ``--tls-password`` option has been added to
492+
``http.server`` to support password-protected private keys. For example, the
493+
following command runs the server with TLS enabled::
494+
495+
python -m http.server --tls-cert cert.pem --tls-key key.pem
496+
497+
.. versionchanged:: 3.14
498+
Added the ``--tls-cert``, ``--tls-key`` and ``--tls-password`` options.
499+
465500
.. class:: CGIHTTPRequestHandler(request, client_address, server)
466501

467502
This class is used to serve either files or output of CGI scripts from the
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
The :mod:`http.server` module now includes built-in support for HTTPS
22
server. New :class:`http.server.HTTPSServer` class is an implementation of
33
HTTPS server that uses :mod:`ssl` module by providing a certificate and
4-
private key. The ``--tls-cert`` and ``--tls-key`` arguments have been added
5-
to ``python -m http.server``. Patch by Semyon Moroz.
4+
private key. The ``--tls-cert``, ``--tls-key`` and ``--tls-password``
5+
arguments have been added to ``python -m http.server``. Patch by Semyon
6+
Moroz.

0 commit comments

Comments
 (0)