Skip to content

Commit

Permalink
redirects control
Browse files Browse the repository at this point in the history
  • Loading branch information
joshburt committed Oct 4, 2024
1 parent 255d5c2 commit f10c47d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ae5_tools/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "."
Expand All @@ -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:
Expand Down

0 comments on commit f10c47d

Please sign in to comment.