mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
keep_alive is now disable-able!
This commit is contained in:
@@ -35,7 +35,7 @@ defaults['timeout'] = None
|
||||
defaults['max_redirects'] = 30
|
||||
defaults['decode_unicode'] = True
|
||||
defaults['timeout_fallback'] = True
|
||||
# defaults['keep_alive'] = True
|
||||
defaults['keep_alive'] = True
|
||||
defaults['pool_connections'] = 10
|
||||
defaults['pool_maxsize'] = 1
|
||||
defaults['max_retries'] = 0
|
||||
|
||||
+8
-2
@@ -20,6 +20,7 @@ from .hooks import dispatch_hook
|
||||
from .structures import CaseInsensitiveDict
|
||||
from .status_codes import codes
|
||||
from .packages.urllib3.exceptions import MaxRetryError
|
||||
from .packages.urllib3 import connectionpool
|
||||
from .exceptions import (
|
||||
Timeout, URLRequired, TooManyRedirects, HTTPError, ConnectionError)
|
||||
from .utils import (
|
||||
@@ -352,7 +353,11 @@ class Request(object):
|
||||
self.__dict__.update(r.__dict__)
|
||||
|
||||
|
||||
conn = self._poolmanager.connection_from_url(url)
|
||||
if self.config.get('keep_alive'):
|
||||
conn = self._poolmanager.connection_from_url(url)
|
||||
else:
|
||||
conn = connectionpool.connection_from_url(url)
|
||||
print 'NO CONNECTION FOR YOU1'
|
||||
|
||||
if not self.sent or anyway:
|
||||
|
||||
@@ -373,7 +378,7 @@ class Request(object):
|
||||
self.headers['Cookie'] = cookie_header
|
||||
|
||||
try:
|
||||
# Create the connection.
|
||||
# Send the request.
|
||||
r = conn.urlopen(
|
||||
method=self.method,
|
||||
url=url,
|
||||
@@ -385,6 +390,7 @@ class Request(object):
|
||||
decode_content=False,
|
||||
retries=self.config.get('max_retries', 0)
|
||||
)
|
||||
|
||||
except MaxRetryError, e:
|
||||
if not self.config.get('safe_mode', False):
|
||||
raise ConnectionError(e)
|
||||
|
||||
+2
-3
@@ -57,6 +57,8 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
# self.httpbin.kill()
|
||||
pass
|
||||
|
||||
|
||||
def test_entry_points(self):
|
||||
|
||||
@@ -551,8 +553,5 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
assert r.content == None
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user