##// END OF EJS Templates
tinyproxy: use IPv6 if HGIPV6 is set to 1...
Jun Wu -
r31005:d8d698bc default
parent child Browse files
Show More
@@ -26,6 +26,11 b' httpserver = util.httpserver'
26 urlparse = util.urlparse
26 urlparse = util.urlparse
27 socketserver = util.socketserver
27 socketserver = util.socketserver
28
28
29 if os.environ.get('HGIPV6', '0') == '1':
30 family = socket.AF_INET6
31 else:
32 family = socket.AF_INET
33
29 class ProxyHandler (httpserver.basehttprequesthandler):
34 class ProxyHandler (httpserver.basehttprequesthandler):
30 __base = httpserver.basehttprequesthandler
35 __base = httpserver.basehttprequesthandler
31 __base_handle = __base.handle
36 __base_handle = __base.handle
@@ -65,7 +70,7 b' class ProxyHandler (httpserver.basehttpr'
65 return 1
70 return 1
66
71
67 def do_CONNECT(self):
72 def do_CONNECT(self):
68 soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
73 soc = socket.socket(family, socket.SOCK_STREAM)
69 try:
74 try:
70 if self._connect_to(self.path, soc):
75 if self._connect_to(self.path, soc):
71 self.log_request(200)
76 self.log_request(200)
@@ -85,7 +90,7 b' class ProxyHandler (httpserver.basehttpr'
85 if scm != 'http' or fragment or not netloc:
90 if scm != 'http' or fragment or not netloc:
86 self.send_error(400, "bad url %s" % self.path)
91 self.send_error(400, "bad url %s" % self.path)
87 return
92 return
88 soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
93 soc = socket.socket(family, socket.SOCK_STREAM)
89 try:
94 try:
90 if self._connect_to(netloc, soc):
95 if self._connect_to(netloc, soc):
91 self.log_request()
96 self.log_request()
General Comments 0
You need to be logged in to leave comments. Login now