from .structures import CaseInsensitiveDict
from .packages.poster.encode import multipart_encode
from .packages.poster.streaminghttp import register_openers, get_handlers
+from .utils import dict_from_cookiejar
from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod
response.headers = CaseInsensitiveDict(getattr(resp.info(), 'dict', None))
response.read = resp.read
response.close = resp.close
+
+ if self.cookiejar:
+
+ response.cookies = dict_from_cookiejar(self.cookiejar)
+
+
except AttributeError:
pass
self.history = []
#: The Request that created the Response.
self.request = None
+ self.cookies = None
def __repr__(self):
--- /dev/null
+# -*- coding: utf-8 -*-
+
+"""
+requests.utils
+~~~~~~~~~~~~~~
+
+This module provides utlity functions that are used within Requests
+that are also useful for external consumption.
+
+"""
+
+
+def dict_from_cookiejar(cookiejar):
+ """Returns a key/value dictoinary from a CookieJar."""
+
+ cookie_dict = {}
+
+ for _, cookies in cookiejar._cookies.items():
+ for _, cookies in cookies.items():
+ for cookie in cookies.values():
+ cookie_dict[cookie.name] = cookie.value
+
+ return cookie_dict
+