aboutsummaryrefslogtreecommitdiff
path: root/requests/sessions.py
diff options
context:
space:
mode:
Diffstat (limited to 'requests/sessions.py')
-rw-r--r--requests/sessions.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/requests/sessions.py b/requests/sessions.py
index 247aa18..d9683b0 100644
--- a/requests/sessions.py
+++ b/requests/sessions.py
@@ -25,7 +25,7 @@ def merge_kwargs(local_kwarg, default_kwarg):
if default_kwarg is None:
return local_kwarg
- if isinstance(local_kwarg, basestring):
+ if isinstance(local_kwarg, str):
return local_kwarg
if local_kwarg is None:
@@ -40,7 +40,7 @@ def merge_kwargs(local_kwarg, default_kwarg):
kwargs.update(local_kwarg)
# Remove keys that are set to None.
- for (k,v) in local_kwarg.items():
+ for (k,v) in list(local_kwarg.items()):
if v is None:
del kwargs[k]
@@ -63,7 +63,8 @@ class Session(object):
proxies=None,
hooks=None,
params=None,
- config=None):
+ config=None,
+ verify=True):
self.headers = headers or {}
self.cookies = cookies or {}
@@ -73,8 +74,9 @@ class Session(object):
self.hooks = hooks or {}
self.params = params or {}
self.config = config or {}
+ self.verify = verify
- for (k, v) in defaults.items():
+ for (k, v) in list(defaults.items()):
self.config.setdefault(k, v)
self.poolmanager = PoolManager(
@@ -111,7 +113,8 @@ class Session(object):
hooks=None,
return_response=True,
config=None,
- prefetch=False):
+ prefetch=False,
+ verify=None):
"""Constructs and sends a :class:`Request <Request>`.
Returns :class:`Response <Response>` object.
@@ -123,13 +126,14 @@ class Session(object):
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.
- :param auth: (optional) Auth typle to enable Basic/Digest/Custom HTTP Auth.
+ :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param return_response: (optional) If False, an un-sent Request object will returned.
:param config: (optional) A configuration dictionary.
:param prefetch: (optional) if ``True``, the response content will be immediately downloaded.
+ :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided.
"""
method = str(method).upper()
@@ -141,13 +145,17 @@ class Session(object):
headers = {} if headers is None else headers
params = {} if params is None else params
hooks = {} if hooks is None else hooks
+
+ if verify is None:
+ verify = self.verify
+
# use session's hooks as defaults
- for key, cb in self.hooks.iteritems():
+ for key, cb in list(self.hooks.items()):
hooks.setdefault(key, cb)
# Expand header values.
if headers:
- for k, v in headers.items() or {}:
+ for k, v in list(headers.items()) or {}:
headers[k] = header_expand(v)
args = dict(
@@ -164,6 +172,7 @@ class Session(object):
allow_redirects=allow_redirects,
proxies=proxies,
config=config,
+ verify=verify,
_poolmanager=self.poolmanager
)