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 2fd09b0

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

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
@@ -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,
+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.