]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38907: In http.server script, restore binding to IPv4 on Windows. (GH-17851)
authorJason R. Coombs <jaraco@jaraco.com>
Mon, 6 Jan 2020 03:32:19 +0000 (22:32 -0500)
committerGitHub <noreply@github.com>
Mon, 6 Jan 2020 03:32:19 +0000 (22:32 -0500)
Lib/http/server.py
Misc/NEWS.d/next/Library/2020-01-06-02-14-38.bpo-38907.F1RkCR.rst [new file with mode: 0644]

index 47a4fcf9a6518fd3f6fbdc633f5ce4d3f9217433..b9a2717681f536d0ad8cd6f18b61a71749ceb7db 100644 (file)
@@ -1282,4 +1282,16 @@ if __name__ == '__main__':
     else:
         handler_class = partial(SimpleHTTPRequestHandler,
                                 directory=args.directory)
-    test(HandlerClass=handler_class, port=args.port, bind=args.bind)
+
+    # ensure dual-stack is not disabled; ref #38907
+    class DualStackServer(ThreadingHTTPServer):
+        def server_bind(self):
+            self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
+            return super().server_bind()
+
+    test(
+        HandlerClass=handler_class,
+        ServerClass=DualStackServer,
+        port=args.port,
+        bind=args.bind,
+    )
diff --git a/Misc/NEWS.d/next/Library/2020-01-06-02-14-38.bpo-38907.F1RkCR.rst b/Misc/NEWS.d/next/Library/2020-01-06-02-14-38.bpo-38907.F1RkCR.rst
new file mode 100644 (file)
index 0000000..a6e79f7
--- /dev/null
@@ -0,0 +1 @@
+In http.server script, restore binding to IPv4 on Windows.
\ No newline at end of file