From f10c47dc85ceab1eb1bfb32c1f4f8373aae099fc Mon Sep 17 00:00:00 2001 From: joshburt Date: Fri, 4 Oct 2024 09:51:55 -0700 Subject: [PATCH] redirects control --- ae5_tools/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ae5_tools/api.py b/ae5_tools/api.py index 415eaf4..1ac44a5 100644 --- a/ae5_tools/api.py +++ b/ae5_tools/api.py @@ -539,6 +539,7 @@ def _format_response(self, response, format, columns=None, record_type=None): def _api(self, method, endpoint, **kwargs): format = kwargs.pop("format", None) subdomain = kwargs.pop("subdomain", None) + override_redirects = kwargs.pop("override_redirects", False) isabs, endpoint = endpoint.startswith("/"), endpoint.lstrip("/") if subdomain: subdomain += "." @@ -556,7 +557,10 @@ def _api(self, method, endpoint, **kwargs): allow_retry = False while True: try: - response = getattr(self.session, method)(url, allow_redirects=False, **kwargs) + if override_redirects: + response = getattr(self.session, method)(url, **kwargs) + else: + response = getattr(self.session, method)(url, allow_redirects=False, **kwargs) except requests.exceptions.ConnectionError: raise AEUnexpectedResponseError("Unable to connect", method, url, **kwargs) except requests.exceptions.Timeout: