Skip to content

Commit

Permalink
Merge pull request iterative#3169 from fabiosantoscode/feature/2963-d…
Browse files Browse the repository at this point in the history
…vc-pull-of-s3-remote-with-https-url

pull: treat HTTP redirects without Location header as error
  • Loading branch information
efiop authored Jan 19, 2020
2 parents 74c5af1 + df22dd4 commit 3987086
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion dvc/remote/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,22 @@ def _request(self, method, url, **kwargs):
kwargs.setdefault("timeout", self.REQUEST_TIMEOUT)

try:
return self._session.request(method, url, **kwargs)
res = self._session.request(method, url, **kwargs)

redirect_no_location = (
kwargs["allow_redirects"]
and res.status_code in (301, 302)
and "location" not in res.headers
)

if redirect_no_location:
# AWS s3 doesn't like to add a location header to its redirects
# from https://s3.amazonaws.com/<bucket name>/* type URLs.
# This should be treated as an error
raise requests.exceptions.RequestException

return res

except requests.exceptions.RequestException:
raise DvcException("could not perform a {} request".format(method))

Expand Down

0 comments on commit 3987086

Please sign in to comment.