keep_alive is now disable-able!
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent 7192b80 · Browse files · 3 files·+11 added−6 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+11 added−6 removed
- other:+11 added−6 removed
Provenance
- Commit
0c4b973- Tree
5fb51a7- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
7192b80
3 files changed+11 added−6 removed
modified:requests/defaults.py+1 added-1 removed
33 unmodified lines34 defaults['timeout'] = None35 defaults['max_redirects'] = 3036 defaults['decode_unicode'] = True37 defaults['timeout_fallback'] = True38-# defaults['keep_alive'] = True38+defaults['keep_alive'] = True39 defaults['pool_connections'] = 1040 defaults['pool_maxsize'] = 141 defaults['max_retries'] = 042 defaults['safe_mode'] = Falsemodified:requests/models.py+8 added-2 removed
18 unmodified lines19 from .hooks import dispatch_hook20 from .structures import CaseInsensitiveDict21 from .status_codes import codes22 from .packages.urllib3.exceptions import MaxRetryError23+from .packages.urllib3 import connectionpool24 from .exceptions import (25 Timeout, URLRequired, TooManyRedirects, HTTPError, ConnectionError)26 from .utils import (27 dict_from_cookiejar, get_unicode_from_response,324 unmodified lines352 353 self.__dict__.update(r.__dict__)354 355 356+ if self.config.get('keep_alive'):355- conn = self._poolmanager.connection_from_url(url)357+ conn = self._poolmanager.connection_from_url(url)358+ else:359+ conn = connectionpool.connection_from_url(url)360+ print 'NO CONNECTION FOR YOU1'361 362 if not self.sent or anyway:363 364 if self.cookies:12 unmodified lines377 # Attach Cookie header to request.378 self.headers['Cookie'] = cookie_header379 380 try:376- # Create the connection.381+ # Send the request.382 r = conn.urlopen(383 method=self.method,384 url=url,385 body=body,3 unmodified lines389 preload_content=False,390 decode_content=False,391 retries=self.config.get('max_retries', 0)392 )393+394 except MaxRetryError, e:395 if not self.config.get('safe_mode', False):396 raise ConnectionError(e)397 else:158 unmodified linesmodified:test_requests.py+2 added-3 removed
55 unmodified lines56 57 def tearDown(self):58 """Teardown."""59 # self.httpbin.kill()60+ pass61 62+63 def test_entry_points(self):64 65 requests.session66 requests.session().get485 unmodified lines552 r = requests.get(hah, allow_redirects=False, config=config)553 assert r.content == None554 555 554-555-556-556 if __name__ == '__main__':557 unittest.main()