]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Add missing `Response.next()` (#1055)
authorFlorimond Manca <florimond.manca@gmail.com>
Tue, 7 Jul 2020 08:54:50 +0000 (10:54 +0200)
committerGitHub <noreply@github.com>
Tue, 7 Jul 2020 08:54:50 +0000 (10:54 +0200)
httpx/_models.py
tests/client/test_redirects.py

index 8221e72f11013a453e183f8b8042fa4685b9acbd..0437de1c4133062064b9b72ba075a33b5711f7f4 100644 (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.
index dea1df284d07ebc7af835dc1bd396d0e689d618b..ae800fa79299bf8a38f5225c9fdeb19e10bde9cb 100644 (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")