Skip to content
Myr

Tracking Previous Requests

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

Addresses the issue brought up here: https://github.com/kennethreitz/requests/issues/1929

authored by ContinuousFunction · committed by ContinuousFunction · parent 35d083e · Browse files · 2 files+15 added−0 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+15 added−0 removed

  • other:+15 added−0 removed

2 files+15 added−0 removed

modified:requests/sessions.py+7 added
89 unmodified lines
90 verify=True, cert=None, proxies=None):91 """Receives a Response. Returns a generator of Responses."""9293 i = 094 hist = [] #keep track of history9596 while resp.is_redirect:97 prepared_request = req.copy()9899 if i > 0:100 #create deep copy of the history and keep track of redirects101 hist.append(resp)102 new_hist = list(hist)103 resp.history = new_hist104105 try:106 resp.content # Consume socket so it can be released107 except (ChunkedEncodingError, ContentDecodingError, RuntimeError):108 resp.raw.read(decode_content=False)
544 unmodified lines
modified:test_requests.py+8 added
972 unmodified lines
973 s = _basic_auth_str("test", "test")974 assert isinstance(s, builtin_str)975 assert s == "Basic dGVzdDp0ZXN0"976977 def test_requests_history_is_saved(self):978 r = requests.get('https://httpbin.org/redirect/5')979 count = 0980 for item in r.history:981 assert len(item.history) == count982 count = count + 1983984985class TestContentEncodingDetection(unittest.TestCase):986987 def test_none(self):988 encodings = requests.utils.get_encodings_from_content('')
381 unmodified lines
1370 TestRedirects.default_keyword_args)1371 assert session.calls[-1] == send_call1372137313741375@pytest.fixture1376def list_of_tuples():1377 return [1378 (('a', 'b'), ('c', 'd')),
55 unmodified lines