diff --git a/requests/sessions.py b/requests/sessions.py index 664465d8..ca7e2170 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -449,6 +449,10 @@ class Session(SessionRedirectMixin): r = dispatch_hook('response', hooks, r, **kwargs) # Persist cookies + if r.history: + # If the hooks create history then we want those cookies too + for resp in r.history: + extract_cookies_to_jar(self.cookies, resp.request, resp.raw) extract_cookies_to_jar(self.cookies, request, r.raw) # Redirect resolving generator. diff --git a/test_requests.py b/test_requests.py index 756bc879..1c581066 100755 --- a/test_requests.py +++ b/test_requests.py @@ -285,7 +285,7 @@ class RequestsTestCase(unittest.TestCase): self.assertEqual(r.status_code, 401) s = requests.session() - s.auth = auth + s.auth = HTTPDigestAuth('user', 'pass') r = s.get(url) self.assertEqual(r.status_code, 200)