Content-Length: 343287 | pFad | http://github.com/python/cpython/commit/2fd09b011031f3c00c342b44e02e2817010e507c

51 gh-134168: fix `http.server` CLI support for IPv6 and `--directory` w… · python/cpython@2fd09b0 · GitHub
Skip to content

Commit 2fd09b0

Browse files
authored
gh-134168: fix http.server CLI support for IPv6 and --directory when serving over HTTPS (#134169)
1 parent 5d9c8fe commit 2fd09b0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Lib/http/server.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,8 @@ def test(HandlerClass=BaseHTTPRequestHandler,
980980
HandlerClass.protocol_version = protocol
981981

982982
if tls_cert:
983-
server = ThreadingHTTPSServer(addr, HandlerClass, certfile=tls_cert,
984-
keyfile=tls_key, password=tls_password)
983+
server = ServerClass(addr, HandlerClass, certfile=tls_cert,
984+
keyfile=tls_key, password=tls_password)
985985
else:
986986
server = ServerClass(addr, HandlerClass)
987987

@@ -1041,7 +1041,7 @@ def _main(args=None):
10411041
parser.error(f"Failed to read TLS password file: {e}")
10421042

10431043
# ensure dual-stack is not disabled; ref #38907
1044-
class DualStackServer(ThreadingHTTPServer):
1044+
class DualStackServerMixin:
10451045

10461046
def server_bind(self):
10471047
# suppress exception when protocol is IPv4
@@ -1054,9 +1054,16 @@ def finish_request(self, request, client_address):
10541054
self.RequestHandlerClass(request, client_address, self,
10551055
directory=args.directory)
10561056

1057+
class HTTPDualStackServer(DualStackServerMixin, ThreadingHTTPServer):
1058+
pass
1059+
class HTTPSDualStackServer(DualStackServerMixin, ThreadingHTTPSServer):
1060+
pass
1061+
1062+
ServerClass = HTTPSDualStackServer if args.tls_cert else HTTPDualStackServer
1063+
10571064
test(
10581065
HandlerClass=SimpleHTTPRequestHandler,
1059-
ServerClass=DualStackServer,
1066+
ServerClass=ServerClass,
10601067
port=args.port,
10611068
bind=args.bind,
10621069
protocol=args.protocol,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:mod:`http.server`: Fix IPv6 address binding and
2+
:option:`--directory <http.server --directory>` handling when using HTTPS.

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/commit/2fd09b011031f3c00c342b44e02e2817010e507c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy