##// END OF EJS Templates
typing: suppress a few attribute errors in url.py...
Matt Harbison -
r50285:9f3edb30 default
parent child Browse files
Show More
@@ -222,13 +222,16 b' def _generic_start_transaction(handler, '
222 h.headers = None
222 h.headers = None
223
223
224
224
225 def _generic_proxytunnel(self):
225 def _generic_proxytunnel(self: "httpsconnection"):
226 headers = self.headers # pytype: disable=attribute-error
226 proxyheaders = {
227 proxyheaders = {
227 pycompat.bytestr(x): pycompat.bytestr(self.headers[x])
228 pycompat.bytestr(x): pycompat.bytestr(headers[x])
228 for x in self.headers
229 for x in headers
229 if x.lower().startswith('proxy-')
230 if x.lower().startswith('proxy-')
230 }
231 }
231 self.send(b'CONNECT %s HTTP/1.0\r\n' % self.realhostport)
232 realhostport = self.realhostport # pytype: disable=attribute-error
233 self.send(b'CONNECT %s HTTP/1.0\r\n' % realhostport)
234
232 for header in proxyheaders.items():
235 for header in proxyheaders.items():
233 self.send(b'%s: %s\r\n' % header)
236 self.send(b'%s: %s\r\n' % header)
234 self.send(b'\r\n')
237 self.send(b'\r\n')
@@ -237,10 +240,14 b' def _generic_proxytunnel(self):'
237 # httplib.HTTPConnection as there are no adequate places to
240 # httplib.HTTPConnection as there are no adequate places to
238 # override functions to provide the needed functionality.
241 # override functions to provide the needed functionality.
239
242
243 # pytype: disable=attribute-error
240 res = self.response_class(self.sock, method=self._method)
244 res = self.response_class(self.sock, method=self._method)
245 # pytype: enable=attribute-error
241
246
242 while True:
247 while True:
248 # pytype: disable=attribute-error
243 version, status, reason = res._read_status()
249 version, status, reason = res._read_status()
250 # pytype: enable=attribute-error
244 if status != httplib.CONTINUE:
251 if status != httplib.CONTINUE:
245 break
252 break
246 # skip lines that are all whitespace
253 # skip lines that are all whitespace
@@ -323,14 +330,15 b' if has_https:'
323 self.sock = socket.create_connection((self.host, self.port))
330 self.sock = socket.create_connection((self.host, self.port))
324
331
325 host = self.host
332 host = self.host
326 if self.realhostport: # use CONNECT proxy
333 realhostport = self.realhostport # pytype: disable=attribute-error
334 if realhostport: # use CONNECT proxy
327 _generic_proxytunnel(self)
335 _generic_proxytunnel(self)
328 host = self.realhostport.rsplit(b':', 1)[0]
336 host = realhostport.rsplit(b':', 1)[0]
329 self.sock = sslutil.wrapsocket(
337 self.sock = sslutil.wrapsocket(
330 self.sock,
338 self.sock,
331 self.key_file,
339 self.key_file,
332 self.cert_file,
340 self.cert_file,
333 ui=self.ui,
341 ui=self.ui, # pytype: disable=attribute-error
334 serverhostname=host,
342 serverhostname=host,
335 )
343 )
336 sslutil.validatesocket(self.sock)
344 sslutil.validatesocket(self.sock)
General Comments 0
You need to be logged in to leave comments. Login now