Skip to content
Myr

Added test case to handle response of streamed redirects.

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

Credits go to @zackw.

authored by schlamar · committed by schlamar · parent 59c8d81 · Browse files · 1 file+20 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

1 file+20 added−1 removed

  • other:+20 added−1 removed

1 file+20 added−1 removed

modified:test_requests.py+20 added-1 removed
915 unmodified lines
916 h2 = r.request.headers['Authorization']917918 assert h1 == h2919920 def test_manual_redirect_with_partial_body_read(self):921 s = requests.Session()922 r1 = s.get(httpbin('redirect/2'), allow_redirects=False, stream=True)923 assert r1.is_redirect924 rg = s.resolve_redirects(r1, r1.request, stream=True)925926 # read only the first eight bytes of the response body,927 # then follow the redirect928 r1.iter_content(8)929 r2 = next(rg)930 assert r2.is_redirect931932 # read all of the response via iter_content,933 # then follow the redirect934 for _ in r2.iter_content():935 pass936 r3 = next(rg)937 assert not r3.is_redirect938939940class TestContentEncodingDetection(unittest.TestCase):941942 def test_none(self):943 encodings = requests.utils.get_encodings_from_content('')
395 unmodified lines
1339 data=data,1340 hooks=default_hooks()1341 )1342 assert p.body == urlencode(data)1324 134313441345if __name__ == '__main__':1346 unittest.main()