Skip to content

Commit

Permalink
NXPY-258: File download from aws S3 with auto-redirect not working in…
Browse files Browse the repository at this point in the history
… case of OAuth 15/04 --002
  • Loading branch information
gitofanindya committed Apr 15, 2024
1 parent 958c88f commit 824ec14
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions nuxeo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,29 +307,27 @@ def request(
verify=ssl_verify,
**kwargs,
)
try:
if resp.status_code == 302:
redirect_url = resp.headers["Location"]
except Exception:
redirect_url = ""
if "amazonaws.com" in redirect_url and resp.status_code == 302:
resp = requests.get(
url=resp.headers["Location"],
headers=resp.headers,
data=data,
allow_redirects=True,
verify=ssl_verify,
**kwargs,
)
elif resp.status_code != 200:
resp = self._session.request(
method,
url,
headers=headers,
auth=auth,
data=data,
verify=ssl_verify,
**kwargs,
)
if "amazonaws.com" in redirect_url:
resp = requests.get(
url=resp.headers["Location"],
headers=resp.headers,
data=data,
allow_redirects=True,
verify=ssl_verify,
**kwargs,
)
else:
resp = self._session.request(
method,
url,
headers=headers,
auth=auth,
data=data,
verify=ssl_verify,
**kwargs,
)
resp.raise_for_status()
except Exception as exc:
if default is object:
Expand Down

0 comments on commit 824ec14

Please sign in to comment.