Skip to content

Commit ee94bdb

Browse files
authored
bpo-38907: In http.server script, restore binding to IPv4 on Windows. (GH-17851)
1 parent d6c08db commit ee94bdb

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
@@ -1282,4 +1282,16 @@ def test(HandlerClass=BaseHTTPRequestHandler,
12821282
else:
12831283
handler_class = partial(SimpleHTTPRequestHandler,
12841284
directory=args.directory)
1285-
test(HandlerClass=handler_class, port=args.port, bind=args.bind)
1285+
1286+
# ensure dual-stack is not disabled; ref #38907
1287+
class DualStackServer(ThreadingHTTPServer):
1288+
def server_bind(self):
1289+
self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
1290+
return super().server_bind()
1291+
1292+
test(
1293+
HandlerClass=handler_class,
1294+
ServerClass=DualStackServer,
1295+
port=args.port,
1296+
bind=args.bind,
1297+
)
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)