bpo-38907: In http.server script, restore binding to IPv4 on Windows. (GH-17851) (#17854)

(cherry picked from commit ee94bdb0598f9bc47d6a49e58fffc97aa617be96)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
diff --git a/Lib/http/server.py b/Lib/http/server.py
index b247675..0fe44bd 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -1280,4 +1280,16 @@
     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,
+    )