Show More
@@ -302,7 +302,7 b' class httpconnection(keepalive.HTTPConne' | |||||
302 | send = _gen_sendfile(keepalive.HTTPConnection) |
|
302 | send = _gen_sendfile(keepalive.HTTPConnection) | |
303 |
|
303 | |||
304 | def connect(self): |
|
304 | def connect(self): | |
305 | if has_https and self.realhost: # use CONNECT proxy |
|
305 | if has_https and self.realhostport: # use CONNECT proxy | |
306 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
306 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
307 | self.sock.connect((self.host, self.port)) |
|
307 | self.sock.connect((self.host, self.port)) | |
308 | if _generic_proxytunnel(self): |
|
308 | if _generic_proxytunnel(self): | |
@@ -335,21 +335,16 b' def _generic_start_transaction(handler, ' | |||||
335 | if new_tunnel or tunnel_host == req.get_full_url(): # has proxy |
|
335 | if new_tunnel or tunnel_host == req.get_full_url(): # has proxy | |
336 | urlparts = urlparse.urlparse(tunnel_host) |
|
336 | urlparts = urlparse.urlparse(tunnel_host) | |
337 | if new_tunnel or urlparts[0] == 'https': # only use CONNECT for HTTPS |
|
337 | if new_tunnel or urlparts[0] == 'https': # only use CONNECT for HTTPS | |
338 |
|
|
338 | realhostport = urlparts[1] | |
339 | realhost, realport = urlparts[1].split(':') |
|
339 | if realhostport[-1] == ']' or ':' not in realhostport: | |
340 |
realport = |
|
340 | realhostport += ':443' | |
341 | else: |
|
|||
342 | realhost = urlparts[1] |
|
|||
343 | realport = 443 |
|
|||
344 |
|
341 | |||
345 | h.realhost = realhost |
|
342 | h.realhostport = realhostport | |
346 | h.realport = realport |
|
|||
347 | h.headers = req.headers.copy() |
|
343 | h.headers = req.headers.copy() | |
348 | h.headers.update(handler.parent.addheaders) |
|
344 | h.headers.update(handler.parent.addheaders) | |
349 | return |
|
345 | return | |
350 |
|
346 | |||
351 | h.realhost = None |
|
347 | h.realhostport = None | |
352 | h.realport = None |
|
|||
353 | h.headers = None |
|
348 | h.headers = None | |
354 |
|
349 | |||
355 | def _generic_proxytunnel(self): |
|
350 | def _generic_proxytunnel(self): | |
@@ -357,7 +352,7 b' def _generic_proxytunnel(self):' | |||||
357 | [(x, self.headers[x]) for x in self.headers |
|
352 | [(x, self.headers[x]) for x in self.headers | |
358 | if x.lower().startswith('proxy-')]) |
|
353 | if x.lower().startswith('proxy-')]) | |
359 | self._set_hostport(self.host, self.port) |
|
354 | self._set_hostport(self.host, self.port) | |
360 |
self.send('CONNECT %s |
|
355 | self.send('CONNECT %s HTTP/1.0\r\n' % self.realhostport) | |
361 | for header in proxyheaders.iteritems(): |
|
356 | for header in proxyheaders.iteritems(): | |
362 | self.send('%s: %s\r\n' % header) |
|
357 | self.send('%s: %s\r\n' % header) | |
363 | self.send('\r\n') |
|
358 | self.send('\r\n') | |
@@ -486,7 +481,7 b' if has_https:' | |||||
486 | getresponse = keepalive.wrapgetresponse(httplib.HTTPSConnection) |
|
481 | getresponse = keepalive.wrapgetresponse(httplib.HTTPSConnection) | |
487 |
|
482 | |||
488 | def connect(self): |
|
483 | def connect(self): | |
489 | if self.realhost: # use CONNECT proxy |
|
484 | if self.realhostport: # use CONNECT proxy | |
490 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
485 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
491 | self.sock.connect((self.host, self.port)) |
|
486 | self.sock.connect((self.host, self.port)) | |
492 | if _generic_proxytunnel(self): |
|
487 | if _generic_proxytunnel(self): |
General Comments 0
You need to be logged in to leave comments.
Login now