Skip to content
Myr

Merge pull request #1239 from miikka/fix-issue-1228

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

Use session cookies when following redirects

authored by Kenneth Reitz · committed by Kenneth Reitz · parents db90d85, 120a2f3 · Browse files · 2 files+10 added−1 removed
This commit

State

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

Diff stats

2 files+10 added−1 removed

  • other:+10 added−1 removed

2 files+10 added−1 removed

modified:requests/sessions.py+4 added-1 removed
88 unmodified lines
89 prepared_request.headers = req.headers.copy()90 prepared_request.hooks = req.hooks91 prepared_request.method = req.method92 prepared_request.url = req.url93 cookiejar = resp.cookies9394 cookiejar = cookiejar_from_dict({})95 cookiejar.update(self.cookies)96 cookiejar.update(resp.cookies)9798 # ((resp.status_code is codes.see_other))99 while (('location' in resp.headers and resp.status_code in REDIRECT_STATI)):100101 resp.content # Consume socket so it can be released
375 unmodified lines
modified:test_requests.py+6 added
116 unmodified lines
117 url = httpbin('cookies/set?foo=bar')118 r = s.get(url)119 self.assertTrue(s.cookies['foo'] == 'bar')120121 def test_cookie_sent_on_redirect(self):122 s = requests.session()123 s.get(httpbin('cookies/set?foo=bar'))124 r = s.get(httpbin('redirect/1')) # redirects to httpbin('get')125 self.assertTrue("Cookie" in r.json()["headers"])126127 def test_user_agent_transfers(self):128129 heads = {130 'User-agent': 'Mozilla/5.0 (github.com/kennethreitz/requests)'
267 unmodified lines