Skip to content
Myr

Added support for persistent connections (keep-alive) in proxy mode

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by László Vaskó · committed by László Vaskó · parent e8d2092 · Browse files · 1 file+16 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+16 added−10 removed

  • other:+16 added−10 removed

1 file+16 added−10 removed

modified:requests/models.py+16 added-10 removed
555 unmodified lines
556 no_proxy = filter(lambda x: x.strip(), self.proxies.get('no', '').split(','))557 proxy = self.proxies.get(_p.scheme)558559 if proxy and not any(map(_p.hostname.endswith, no_proxy)):560 conn = poolmanager.proxy_from_url(proxy)560 conn = poolmanager.ProxyManager(self.get_connection_for_url(proxy))561 _proxy = urlparse(proxy)562 if '@' in _proxy.netloc:563 auth, url = _proxy.netloc.split('@', 1)564 self.proxy_auth = HTTPProxyAuth(*auth.split(':', 1))565 r = self.proxy_auth(self)566 self.__dict__.update(r.__dict__)567 else:568 # Check to see if keep_alive is allowed.569 try:570 if self.config.get('keep_alive'):571 conn = self._poolmanager.connection_from_url(url)572 else:573 conn = connectionpool.connection_from_url(url)574 self.headers['Connection'] = 'close'575 except LocationParseError as e:576 raise InvalidURL(e)568 conn = self.get_connection_for_url(url)569570 if not self.config.get('keep_alive'):571 self.headers['Connection'] = 'close'572573 if url.startswith('https') and self.verify:574575 cert_loc = None576
89 unmodified lines
666 self.response.content667668 return self.sent669670 def get_connection_for_url(self, url):671 # Check to see if keep_alive is allowed.672 try:673 if self.config.get('keep_alive'):674 conn = self._poolmanager.connection_from_url(url)675 else:676 conn = connectionpool.connection_from_url(url)677 return conn678 except LocationParseError as e:679 raise InvalidURL(e)680681682class Response(object):683 """The core :class:`Response <Response>` object. All684 :class:`Request <Request>` objects contain a685 :class:`response <Response>` attribute, which is an instance
234 unmodified lines