if not self.sent or anyway:
- if self.cookies:
-
- # Skip if 'cookie' header is explicitly set.
- if 'cookie' not in self.headers:
-
- # Simple cookie with our dict.
- c = SimpleCookie()
- for (k, v) in list(self.cookies.items()):
- c[k] = v
-
- # Turn it into a header.
- cookie_header = c.output(header='', sep='; ').strip()
-
- # Attach Cookie header to request.
+ # Skip if 'cookie' header is explicitly set.
+ if 'cookie' not in self.headers:
+ cookie_header = get_cookie_header(self.cookies, self)
+ if cookie_header is not None:
self.headers['Cookie'] = cookie_header
- # Pre-request hook.
- r = dispatch_hook('pre_request', self.hooks, self)
- self.__dict__.update(r.__dict__)
-
try:
# The inner try .. except re-raises certain exceptions as
# internal exception types; the outer suppresses exceptions