diff --git a/googleapiclient/http.py b/googleapiclient/http.py index 5b5ea159897..719664de1c9 100644 --- a/googleapiclient/http.py +++ b/googleapiclient/http.py @@ -1886,4 +1886,11 @@ def build_http(): http_timeout = socket.getdefaulttimeout() else: http_timeout = DEFAULT_HTTP_TIMEOUT_SEC - return httplib2.Http(timeout=http_timeout) + http = httplib2.Http(timeout=http_timeout) + # 308's are used by several Google APIs (Drive, YouTube) + # for Resumable Uploads rather than Permanent Redirects. + # This asks httplib2 to exclude 308s from the status codes + # it treats as redirects + http.redirect_codes = http.redirect_codes - {308} + + return http diff --git a/setup.py b/setup.py index 643df2ed7cc..617515bd1c0 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ packages = ["apiclient", "googleapiclient", "googleapiclient/discovery_cache"] install_requires = [ - "httplib2>=0.9.2,<1dev", + "httplib2>=0.17.0,<1dev", "google-auth>=1.4.1", "google-auth-httplib2>=0.0.3", "six>=1.6.1,<2dev", diff --git a/tests/test_http.py b/tests/test_http.py index 1b0caa5b707..2bf5060c0fd 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -1647,6 +1647,10 @@ def test_build_http_default_timeout_can_be_set_to_zero(self): socket.setdefaulttimeout(0) http = build_http() self.assertEquals(http.timeout, 0) + + def test_build_http_default_308_is_excluded_as_redirect(self): + http = build_http() + self.assertTrue(308 not in http.redirect_codes) if __name__ == "__main__":