Skip to content

Commit 5ed9d60

Browse files
bpo-38907: In http.server script, restore binding to IPv4 on Windows. (GH-17851) (#17854)
(cherry picked from commit ee94bdb) Co-authored-by: Jason R. Coombs <[email protected]> Co-authored-by: Jason R. Coombs <[email protected]>
1 parent 5a065ac commit 5ed9d60

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Lib/http/server.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,4 +1280,16 @@ def test(HandlerClass=BaseHTTPRequestHandler,
12801280
else:
12811281
handler_class = partial(SimpleHTTPRequestHandler,
12821282
directory=args.directory)
1283-
test(HandlerClass=handler_class, port=args.port, bind=args.bind)
1283+
1284+
# ensure dual-stack is not disabled; ref #38907
1285+
class DualStackServer(ThreadingHTTPServer):
1286+
def server_bind(self):
1287+
self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
1288+
return super().server_bind()
1289+
1290+
test(
1291+
HandlerClass=handler_class,
1292+
ServerClass=DualStackServer,
1293+
port=args.port,
1294+
bind=args.bind,
1295+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In http.server script, restore binding to IPv4 on Windows.

0 commit comments

Comments
 (0)