Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion googleapiclient/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down