Skip to content
Myr

Store the request cookiejar in PreparedRequest.cookies fix #1728

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Conflicts: requests/sessions.py

authored by Chase Sterling · committed by Ian Cordasco · parent 5b30e96 · Browse files · 3 files+14 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+14 added−11 removed

  • other:+14 added−11 removed

3 files+14 added−11 removed

modified:requests/auth.py+3 added-1 removed
14 unmodified lines
1516from base64 import b64encode1718from .compat import urlparse, str19from .cookies import extract_cookies_to_jar20from .utils import parse_dict_header2122log = logging.getLogger(__name__)23
145 unmodified lines
169 # to allow our new request to reuse the same one.170 r.content171 r.raw.release_conn()172 prep = r.request.copy()173 extract_cookies_to_jar(prep.cookies, r.request, r.raw)172 prep.prepare_cookies(r.cookies)174 prep.prepare_cookies(prep.cookies)175176 prep.headers['Authorization'] = self.build_digest_header(177 prep.method, prep.url)178 _r = r.connection.send(prep, **kwargs)
18 unmodified lines
modified:requests/models.py+9 added-6 removed
268 unmodified lines
269 #: HTTP URL to send the request to.270 self.url = None271 #: dictionary of HTTP headers.272 self.headers = None273 #: The `CookieJar` used to create the Cookie header will be stored here274 #: after prepare_cookies is called275 self.cookies = None276 #: request body to send to the server.277 self.body = None278 #: dictionary of callback hooks, for internal usage.279 self.hooks = default_hooks()
21 unmodified lines
301 p = PreparedRequest()302 p.method = self.method303 p.url = self.url304 p.headers = self.headers.copy()305 p.cookies = self.cookies.copy()306 p.body = self.body307 p.hooks = self.hooks308 return p309
167 unmodified lines
477 def prepare_cookies(self, cookies):478 """Prepares the given HTTP cookie data."""479480 if isinstance(cookies, cookielib.CookieJar):477 cookies = cookies481 self.cookies = cookies482 else:479 cookies = cookiejar_from_dict(cookies)483 self.cookies = cookiejar_from_dict(cookies)484481 if 'cookie' not in self.headers:482 cookie_header = get_cookie_header(cookies, self)483 if cookie_header is not None:484 self.headers['Cookie'] = cookie_header485 cookie_header = get_cookie_header(self.cookies, self)486 if cookie_header is not None:487 self.headers['Cookie'] = cookie_header488489 def prepare_hooks(self, hooks):490 """Prepares the given hooks."""491 for event in hooks:
282 unmodified lines
modified:requests/sessions.py+2 added-4 removed
151 unmodified lines
152 del headers['Cookie']153 except KeyError:154 pass155156 extract_cookies_to_jar(prepared_request.cookies, prepared_request, resp.raw)156 prepared_request.prepare_cookies(self.cookies)157 prepared_request.prepare_cookies(prepared_request.cookies)158159 resp = self.send(160 prepared_request,161 stream=stream,
183 unmodified lines
345 hooks = hooks,346 )347 prep = self.prepare_request(req)348348 # Add param cookies to session cookies349 self.cookies = merge_cookies(self.cookies, cookies)350349 proxies = proxies or {}350351 # Gather clues from the surrounding environment.352 if self.trust_env:
199 unmodified lines