pull: treat HTTP redirects without Location header as error

Fixes #2963
This commit is contained in:
Fábio Santos
2020-01-16 14:21:59 +00:00
parent 1f1fb03138
commit 968e74890d
+8 -1
View File
@@ -101,7 +101,14 @@ class RemoteHTTP(RemoteBASE):
kwargs.setdefault("timeout", self.REQUEST_TIMEOUT)
try:
return self._session.request(method, url, **kwargs)
res = self._session.request(method, url, **kwargs)
if kwargs["allow_redirects"] and res.is_redirect:
# 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
except requests.exceptions.RequestException:
raise DvcException("could not perform a {} request".format(method))