From: Florimond Manca Date: Tue, 7 Jul 2020 08:54:50 +0000 (+0200) Subject: Add missing `Response.next()` (#1055) X-Git-Tag: 0.14.0~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3230cb31330bf7d9580d61885d10d3f3805885f4;p=thirdparty%2Fhttpx.git Add missing `Response.next()` (#1055) --- diff --git a/httpx/_models.py b/httpx/_models.py index 8221e72f..0437de1c 100644 --- a/httpx/_models.py +++ b/httpx/_models.py @@ -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. diff --git a/tests/client/test_redirects.py b/tests/client/test_redirects.py index dea1df28..ae800fa7 100644 --- a/tests/client/test_redirects.py +++ b/tests/client/test_redirects.py @@ -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")