Skip cookie extraction if necessary
authorIan Cordasco <graffatcolmingov@gmail.com>
Sat, 17 Aug 2013 02:38:20 +0000 (21:38 -0500)
committerIan Cordasco <graffatcolmingov@gmail.com>
Sat, 17 Aug 2013 02:38:20 +0000 (21:38 -0500)
If _original_response is never set/is None, then don't try to extract cookies
from the response.

requests/cookies.py

index 3bfedcc49f432159375c74c67bab5a5a9e7f4243..f3ac64f0a3aabe3bf778dbc64d23868f8bf416e9 100644 (file)
@@ -107,6 +107,9 @@ def extract_cookies_to_jar(jar, request, response):
     :param request: our own requests.Request object
     :param response: urllib3.HTTPResponse object
     """
+    if not (hasattr(response, '_original_response') and
+            response._original_response):
+        return
     # the _original_response field is the wrapped httplib.HTTPResponse object,
     req = MockRequest(request)
     # pull out the HTTPMessage with the headers and put it in the mock: