From 968e74890ded0a3fef2550f1c4c68daaab80842b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Santos?= Date: Thu, 16 Jan 2020 14:21:59 +0000 Subject: [PATCH] pull: treat HTTP redirects without Location header as error Fixes #2963 --- dvc/remote/http.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dvc/remote/http.py b/dvc/remote/http.py index caa094b97..6879e1436 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -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//* 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))