mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Move session cookie saving from Session.request() to Request._build_response()
This commit is contained in:
@@ -203,6 +203,12 @@ class Request(object):
|
||||
# Save cookies in Response.
|
||||
response.cookies = self.cookies
|
||||
|
||||
# Save cookies in Session.
|
||||
# (in safe mode, cookies may be None if the request didn't succeed)
|
||||
if self.cookies is not None:
|
||||
for cookie in self.cookies:
|
||||
self.session.cookies.set_cookie(cookie)
|
||||
|
||||
# No exceptions were harmed in the making of this request.
|
||||
response.error = getattr(resp, 'error', None)
|
||||
|
||||
|
||||
@@ -228,12 +228,6 @@ class Session(object):
|
||||
# Send the HTTP Request.
|
||||
r.send(prefetch=prefetch)
|
||||
|
||||
# Send any cookies back up the to the session.
|
||||
# (in safe mode, cookies may be None if the request didn't succeed)
|
||||
if r.response.cookies is not None:
|
||||
for cookie in r.response.cookies:
|
||||
self.cookies.set_cookie(cookie)
|
||||
|
||||
# Return the response.
|
||||
return r.response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user