From 97815c9930e20d6cf378681bb39a57ebe6e3b2b8 Mon Sep 17 00:00:00 2001 From: Brendan Maguire Date: Tue, 28 Feb 2012 20:02:21 +0000 Subject: [PATCH] Prefetch for sessions --- AUTHORS.rst | 1 + requests/sessions.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index bf9d279..85bc048 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -84,3 +84,4 @@ Patches and Suggestions - Matt Giuca - Adam Tauber - Honza Javorek +- Brendan Maguire diff --git a/requests/sessions.py b/requests/sessions.py index 29ae1d9..4afcc81 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -64,6 +64,7 @@ class Session(object): hooks=None, params=None, config=None, + prefetch=False, verify=True): self.headers = headers or {} @@ -74,6 +75,7 @@ class Session(object): self.hooks = hooks or {} self.params = params or {} self.config = config or {} + self.prefetch = prefetch self.verify = verify for (k, v) in list(defaults.items()): @@ -148,6 +150,7 @@ class Session(object): headers = {} if headers is None else headers params = {} if params is None else params hooks = {} if hooks is None else hooks + prefetch = self.prefetch or prefetch # use session's hooks as defaults for key, cb in list(self.hooks.items()): @@ -172,6 +175,7 @@ class Session(object): allow_redirects=allow_redirects, proxies=proxies, config=config, + prefetch=prefetch, verify=verify, _poolmanager=self.poolmanager ) -- 2.7.4