Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing Response.next() #1055

Merged
merged 1 commit into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions httpx/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,15 @@ def iter_raw(self) -> typing.Iterator[bytes]:
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.
Expand Down
2 changes: 1 addition & 1 deletion tests/client/test_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down