Skip to content

gh-85162: Add HTTPSServer to http.server #129607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Apr 5, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5bfc939
Add support HTTPS in http.server
donBarbos Feb 2, 2025
b382985
Correct style code
donBarbos Feb 2, 2025
4cc80c5
Add tests for HTTPSServer
donBarbos Feb 2, 2025
75fff2b
Update options
donBarbos Feb 3, 2025
64c3070
Update docs
donBarbos Feb 3, 2025
e4652a7
Merge branch 'main' into issue-85162
donBarbos Feb 3, 2025
abd949c
Revert "Correct style code"
donBarbos Feb 3, 2025
8fc2311
Merge branch 'main' into issue-85162
donBarbos Feb 3, 2025
4f587bd
Update docs and correct raising errors
donBarbos Feb 3, 2025
db796cd
Add helper method _create_context
donBarbos Feb 3, 2025
96d4a68
Update docs and replace password option
donBarbos Feb 4, 2025
947f581
Update Lib/http/server.py
donBarbos Feb 15, 2025
b8ba151
Update Doc/library/http.server.rst
donBarbos Feb 15, 2025
97e2032
Update Doc/library/http.server.rst
donBarbos Feb 15, 2025
bd97fd6
Update Doc/library/http.server.rst
donBarbos Feb 15, 2025
15b2581
Update Doc/library/http.server.rst
donBarbos Feb 15, 2025
1951e22
Update Doc/library/http.server.rst
donBarbos Feb 15, 2025
b4e1eba
Update Lib/http/server.py
donBarbos Feb 15, 2025
4838ff8
Update Lib/http/server.py
donBarbos Feb 15, 2025
3a7821f
Update Lib/http/server.py
donBarbos Feb 15, 2025
85ee1b5
Update Lib/http/server.py
donBarbos Feb 15, 2025
196e71d
Update Doc/library/http.server.rst
donBarbos Feb 15, 2025
efd44a4
Update Doc/library/http.server.rst
donBarbos Feb 15, 2025
4b33ecc
Update Doc/whatsnew/3.14.rst
donBarbos Feb 15, 2025
5fcc947
Update Doc/whatsnew/3.14.rst
donBarbos Feb 15, 2025
4df61de
Update Lib/http/server.py
donBarbos Feb 15, 2025
08a5720
Add suggestions
donBarbos Feb 15, 2025
43ae6b8
Merge branch 'main' into issue-85162
donBarbos Feb 15, 2025
6cff350
Update 2025-02-02-00-30-09.gh-issue-85162.BNF_aJ.rst
donBarbos Feb 15, 2025
0b2d50a
Update http.server.rst
donBarbos Feb 15, 2025
8a7f316
Move function back
donBarbos Feb 15, 2025
e7d9250
Add test case for pass certdata
donBarbos Feb 15, 2025
1b64e3d
Update test_httpservers.py
donBarbos Feb 15, 2025
c004b71
Update test_httpservers.py
donBarbos Feb 15, 2025
b6ba37f
Update test_httpservers.py
donBarbos Feb 15, 2025
bf86a0d
Update test_httpservers.py
donBarbos Feb 15, 2025
b89f4c4
Update test_httpservers.py
donBarbos Feb 15, 2025
c6879de
Update test_httpservers.py
donBarbos Feb 15, 2025
1ee542f
Update test_httpservers.py
donBarbos Feb 15, 2025
0c40dd7
Add more suggestions
donBarbos Feb 15, 2025
6e51ec3
Update docs
donBarbos Feb 15, 2025
4b85253
Update
donBarbos Feb 15, 2025
09d32b3
Update tests
donBarbos Feb 15, 2025
4b8786f
Correct style code
donBarbos Feb 15, 2025
96ba50d
Wrap the lines
donBarbos Feb 15, 2025
5d87f80
Wrap again
donBarbos Feb 15, 2025
05f5f65
Add seealso section
donBarbos Feb 15, 2025
e7a42f7
Update http.server.rst
donBarbos Feb 15, 2025
4c68c27
Merge branch 'main' into issue-85162
donBarbos Mar 16, 2025
3ca55d1
Update cli description
donBarbos Mar 16, 2025
3daf484
Update doc
donBarbos Mar 16, 2025
8b84be2
Update docs
donBarbos Apr 4, 2025
50e0ed5
Update Doc/whatsnew/3.14.rst
picnixz Apr 5, 2025
4f36fbf
Update Doc/whatsnew/3.14.rst
picnixz Apr 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Doc/library/http.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ The :class:`HTTPServer` and :class:`ThreadingHTTPServer` must be given
a *RequestHandlerClass* on instantiation, of which this module
provides three different variants:

.. class:: HTTPSServer(server_address, RequestHandlerClass, \
bind_and_activate=True, *, certfile, keyfile=None, \
password=None, alpn_protocols=None)

This class is a :class:`HTTPServer` subclass with a wrapped socket using the
:mod:`ssl`, if the :mod:`ssl` module is not available the class will not
initialize. The *certfile* argument is required and is the path to the SSL
certificate chain file. The *keyfile* is the path to its private key. But
private keys are often protected and wrapped with PKCS #8, so we provide
*password* argument for that case.

.. versionadded:: 3.14

.. class:: ThreadingHTTPSServer(server_address, RequestHandlerClass, \
bind_and_activate=True, *, certfile, keyfile=None, \
password=None, alpn_protocols=None)

This class is identical to :class:`HTTPSServer` but uses threads to handle
requests by using the :class:`~socketserver.ThreadingMixIn`. This is
analogue of :class:`ThreadingHTTPServer` class only using
:class:`HTTPSServer`.

.. versionadded:: 3.14

.. class:: BaseHTTPRequestHandler(request, client_address, server)

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

The server can also support TLS encryption. The options ``--tls-cert`` and
``--tls-key`` allow specifying a TLS certificate chain and private key for
secure HTTPS connections. And ``--tls-password`` option has been added to
``http.server`` to support password-protected private keys. For example, the
following command runs the server with TLS enabled::

python -m http.server --tls-cert cert.pem --tls-key key.pem

.. versionchanged:: 3.14
Added the ``--tls-cert``, ``--tls-key`` and ``--tls-password`` options.

.. class:: CGIHTTPRequestHandler(request, client_address, server)

This class is used to serve either files or output of CGI scripts from the
Expand Down
Loading
Loading