Skip to content
Myr

Merge pull request #577 from slingamn/redirects_537

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

Fix and test for #537

authored by Kenneth Reitz · committed by Kenneth Reitz · parents a3e5563, 9bf5367 · Browse files · 2 files+14 added−2 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+14 added−2 removed

  • tests:+10 added−0 removed
  • other:+4 added−2 removed

2 files+14 added−2 removed

modified:requests/sessions.py+4 added-2 removed
227 unmodified lines
228 # Send the HTTP Request.229 r.send(prefetch=prefetch)230231 # Send any cookies back up the to the session.232 # (in safe mode, cookies may be None if the request didn't succeed)233 if r.response.cookies is not None:232 for cookie in r.response.cookies:233 self.cookies.set_cookie(cookie)234 for cookie in r.response.cookies:235 self.cookies.set_cookie(cookie)236237 # Return the response.238 return r.response239
90 unmodified lines
modified:tests/test_requests.py+10 added
845 unmodified lines
846 def test_empty_response(self):847 r = requests.get(httpbin('status', '404'))848 r.text849850 def test_max_redirects(self):851 def unsafe_callable():852 requests.get("http://httpbin.org/redirect/3", config=dict(max_redirects=2))853 self.assertRaises(requests.exceptions.TooManyRedirects, unsafe_callable)854855 # add safe mode856 response = requests.get("http://httpbin.org/redirect/3", config=dict(safe_mode=True, max_redirects=2))857 self.assertTrue(response.content is None)858 self.assertTrue(isinstance(response.error, requests.exceptions.TooManyRedirects))859860if __name__ == '__main__':861 unittest.main()