From 3a54d56ce8226bad9187c16b211a147f54afe25e Mon Sep 17 00:00:00 2001 From: Erik Dominguez Date: Sun, 23 Aug 2015 13:15:22 -0700 Subject: [PATCH] added requests arguments to session #105 Added the ability to pass session wide parameters to the requests.Session object. --- slumber/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/slumber/__init__.py b/slumber/__init__.py index 586ebca..2069482 100644 --- a/slumber/__init__.py +++ b/slumber/__init__.py @@ -193,13 +193,23 @@ class API(ResourceAttributesMixin, object): resource_class = Resource - def __init__(self, base_url=None, auth=None, format=None, append_slash=True, session=None, serializer=None): + def __init__(self, base_url=None, auth=None, format=None, append_slash=True, session=None, serializer=None,session_params={}): if serializer is None: serializer = Serializer(default=format) if session is None: session = requests.session() - + + stream = session_params.pop('stream',False) + proxies = session_params.pop('proxies',{}) + verify = session_params.pop('verify',True) + headers = session_params.pop('headers',{}) + + session.stream = stream + session.proxies = proxies + session.verify = verify + session.headers.update(headers) + if auth is not None: session.auth = auth