header and cookie fixes for redirects
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent 0c4b973 · Browse files · 1 file·+22 added−5 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+22 added−5 removed
- other:+22 added−5 removed
Provenance
- Commit
52a95cb- Tree
d20f840- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
0c4b973
1 file changed+22 added−5 removed
modified:requests/models.py+22 added-5 removed
182 unmodified lines183 184 history = []185 186 r = build(resp)187+ cookies = self.cookies188+ self.cookies.update(r.cookies)189 190 if r.status_code in REDIRECT_STATI and not self.redirect:191 192 while (23 unmodified lines216 method = 'GET'217 else:218 method = self.method219 220+ # Remove the cookie headers that were sent.221+ headers = self.headers222+ try:223+ del headers['Cookie']224+ except KeyError:225+ pass226+227 request = Request(228 url=url,220- headers=self.headers,229+ headers=headers,230 files=self.files,231 method=method,223- # data=self.data,232 # params=self.params,233 auth=self._auth,226- cookies=self.cookies,234+ cookies=cookies,235 redirect=True,236 config=self.config,237 _poolmanager=self._poolmanager238 )239+240 request.send()241+ cookies.update(request.response.cookies)242 r = request.response243+ self.cookies.update(r.cookies)244 245 r.history = history246 247 self.response = r248 self.response.request = self249+ # print locals()250+ self.response.cookies.update(self.cookies)251+ # print cookies252+ # print self.response.cookies253+ # print '!!!'254 255 256 @staticmethod257 def _encode_params(data):105 unmodified lines363 364 if self.auth:365 auth_func, auth_args = self.auth366 367+ # Allow auth to make its changes.368 r = auth_func(self, *auth_args)369 370+ # Update self to reflect the auth changes.371 self.__dict__.update(r.__dict__)372 355-373+ # Check to see if keep_alive is allowed.374 if self.config.get('keep_alive'):375 conn = self._poolmanager.connection_from_url(url)376 else:377 conn = connectionpool.connection_from_url(url)360- print 'NO CONNECTION FOR YOU1'378 379 if not self.sent or anyway:380 381 if self.cookies:191 unmodified lines