[PATCH 3 of 8 ipv6] tinyproxy: use IPv6 if HGIPV6 is set to 1
Jun Wu
quark at fb.com
Thu Feb 16 12:39:15 EST 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1487228025 28800
# Wed Feb 15 22:53:45 2017 -0800
# Node ID 72115e4deca500bd6da1929479a966b8b0eb0e1d
# Parent 28bb800077fd83098320b6f21334a71eedf03bbe
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 72115e4deca5
tinyproxy: use IPv6 if HGIPV6 is set to 1
This patch makes tinyproxy.py work in IPv6 mode if HGIPV6 is set to 1.
This will make test-http-proxy.t pass on IPv6 machines.
diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -27,4 +27,9 @@ urlparse = util.urlparse
socketserver = util.socketserver
+if os.environ.get('HGIPV6', '0') == '1':
+ family = socket.AF_INET6
+else:
+ family = socket.AF_INET
+
class ProxyHandler (httpserver.basehttprequesthandler):
__base = httpserver.basehttprequesthandler
@@ -66,5 +71,5 @@ class ProxyHandler (httpserver.basehttpr
def do_CONNECT(self):
- soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ soc = socket.socket(family, socket.SOCK_STREAM)
try:
if self._connect_to(self.path, soc):
@@ -86,5 +91,5 @@ class ProxyHandler (httpserver.basehttpr
self.send_error(400, "bad url %s" % self.path)
return
- soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ soc = socket.socket(family, socket.SOCK_STREAM)
try:
if self._connect_to(netloc, soc):
More information about the Mercurial-devel
mailing list