Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 81f0993

Browse filesBrowse files
picnixzggqlq
andauthored
[3.14] gh-134168: fix http.server CLI support for IPv6 and --directory when serving over HTTPS (GH-134169) (#134630)
[3.14] gh-134168: fix `http.server` CLI support for IPv6 and `--directory` when serving over HTTPS (GH-134169) (cherry picked from commit 2fd09b0) Co-authored-by: ggqlq <124190229+ggqlq@users.noreply.github.com>
1 parent 162e3f3 commit 81f0993
Copy full SHA for 81f0993

File tree

Expand file treeCollapse file tree

2 files changed

+13
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-4
lines changed

‎Lib/http/server.py

Copy file name to clipboardExpand all lines: Lib/http/server.py
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,8 @@ def test(HandlerClass=BaseHTTPRequestHandler,
13201320
HandlerClass.protocol_version = protocol
13211321

13221322
if tls_cert:
1323-
server = ThreadingHTTPSServer(addr, HandlerClass, certfile=tls_cert,
1324-
keyfile=tls_key, password=tls_password)
1323+
server = ServerClass(addr, HandlerClass, certfile=tls_cert,
1324+
keyfile=tls_key, password=tls_password)
13251325
else:
13261326
server = ServerClass(addr, HandlerClass)
13271327

@@ -1387,7 +1387,7 @@ def test(HandlerClass=BaseHTTPRequestHandler,
13871387
handler_class = SimpleHTTPRequestHandler
13881388

13891389
# ensure dual-stack is not disabled; ref #38907
1390-
class DualStackServer(ThreadingHTTPServer):
1390+
class DualStackServerMixin:
13911391

13921392
def server_bind(self):
13931393
# suppress exception when protocol is IPv4
@@ -1400,9 +1400,16 @@ def finish_request(self, request, client_address):
14001400
self.RequestHandlerClass(request, client_address, self,
14011401
directory=args.directory)
14021402

1403+
class HTTPDualStackServer(DualStackServerMixin, ThreadingHTTPServer):
1404+
pass
1405+
class HTTPSDualStackServer(DualStackServerMixin, ThreadingHTTPSServer):
1406+
pass
1407+
1408+
ServerClass = HTTPSDualStackServer if args.tls_cert else HTTPDualStackServer
1409+
14031410
test(
14041411
HandlerClass=handler_class,
1405-
ServerClass=DualStackServer,
1412+
ServerClass=ServerClass,
14061413
port=args.port,
14071414
bind=args.bind,
14081415
protocol=args.protocol,
+2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.