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
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 (
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:
self.headers['Cookie'] = cookie_header
try:
- # Create the connection.
+ # Send the request.
r = conn.urlopen(
method=self.method,
url=url,
decode_content=False,
retries=self.config.get('max_retries', 0)
)
+
except MaxRetryError, e:
if not self.config.get('safe_mode', False):
raise ConnectionError(e)