diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-01-06 03:32:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-06 03:32:19 (GMT) |
commit | ee94bdb0598f9bc47d6a49e58fffc97aa617be96 (patch) | |
tree | a31c23583b078c933af4ac4adeba4fa018216f24 /Lib/http/server.py | |
parent | d6c08db8538d046d783db44fe4e70a60af0fb02e (diff) | |
download | cpython-ee94bdb0598f9bc47d6a49e58fffc97aa617be96.zip cpython-ee94bdb0598f9bc47d6a49e58fffc97aa617be96.tar.gz cpython-ee94bdb0598f9bc47d6a49e58fffc97aa617be96.tar.bz2 |
bpo-38907: In http.server script, restore binding to IPv4 on Windows. (GH-17851)
Diffstat (limited to 'Lib/http/server.py')
-rw-r--r-- | Lib/http/server.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index 47a4fcf..b9a2717 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -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, + ) |