Restore follow_redirects after mediadownload is done.
Reviewed in https://codereview.appspot.com/10238046/
Fixes issue 280.
diff --git a/apiclient/http.py b/apiclient/http.py
index b9cbfd7..b73014a 100644
--- a/apiclient/http.py
+++ b/apiclient/http.py
@@ -505,6 +505,8 @@
self._progress = 0
self._total_size = None
self._done = False
+ self._original_follow_redirects = request.http.follow_redirects
+ request.http.follow_redirects = False
def next_chunk(self):
"""Get the next chunk of the download.
@@ -523,7 +525,6 @@
self._progress, self._progress + self._chunksize)
}
http = self._request.http
- http.follow_redirects = False
resp, content = http.request(self._uri, headers=headers)
if resp.status in [301, 302, 303, 307, 308] and 'location' in resp:
@@ -540,6 +541,7 @@
if self._progress == self._total_size:
self._done = True
+ self._request.http.follow_redirects = self._original_follow_redirects
return MediaDownloadProgress(self._progress, self._total_size), self._done
else:
raise HttpError(resp, content, uri=self._uri)