##// END OF EJS Templates
url: drop compatibility wrapper of socket.create_connection()...
Yuya Nishihara -
r29662:b76ea138 default
parent child Browse files
Show More
@@ -151,35 +151,6 b' def _gen_sendfile(orgsend):'
151 151 return _sendfile
152 152
153 153 has_https = util.safehasattr(urlreq, 'httpshandler')
154 if has_https:
155 try:
156 _create_connection = socket.create_connection
157 except AttributeError:
158 _GLOBAL_DEFAULT_TIMEOUT = object()
159
160 def _create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
161 source_address=None):
162 # lifted from Python 2.6
163
164 msg = "getaddrinfo returns an empty list"
165 host, port = address
166 for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
167 af, socktype, proto, canonname, sa = res
168 sock = None
169 try:
170 sock = socket.socket(af, socktype, proto)
171 if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
172 sock.settimeout(timeout)
173 if source_address:
174 sock.bind(source_address)
175 sock.connect(sa)
176 return sock
177
178 except socket.error as msg:
179 if sock is not None:
180 sock.close()
181
182 raise socket.error(msg)
183 154
184 155 class httpconnection(keepalive.HTTPConnection):
185 156 # must be able to send big bundle as stream.
@@ -337,7 +308,7 b' if has_https:'
337 308 self.cert_file = cert_file
338 309
339 310 def connect(self):
340 self.sock = _create_connection((self.host, self.port))
311 self.sock = socket.create_connection((self.host, self.port))
341 312
342 313 host = self.host
343 314 if self.realhostport: # use CONNECT proxy
General Comments 0
You need to be logged in to leave comments. Login now