Add missing Response.next() (#1055)

This commit is contained in:
Florimond Manca 2020-07-07 10:54:50 +02:00 committed by GitHub
parent 330a82508d
commit 3230cb3133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -943,6 +943,15 @@ class Response:
yield part
self.close()
def next(self) -> "Response":
"""
Get the next response from a redirect response.
"""
if not self.is_redirect:
raise NotRedirectResponse()
assert self.call_next is not None
return self.call_next()
def close(self) -> None:
"""
Close the response and release the connection.

View File

@ -310,7 +310,7 @@ def test_sync_too_many_redirects_calling_next():
response = client.get(url, allow_redirects=False)
with pytest.raises(TooManyRedirects):
while response.is_redirect:
response = response.call_next()
response = response.next()
@pytest.mark.usefixtures("async_environment")