httplib2 RedirectMissingLocation: Redirected but the response is missing a Location: header.
See original GitHub issueEnvironment details
- OS type and version: Ubuntu16.04
- Python version: python3.6 x64
- pip version: 20.1
google-api-python-client
version: 1.8.2httplib2
version: 0.17.3
Steps to reproduce
- upload file
Code example
file_metadata = {"name": file_name, "parents": [parent_id]}
media = MediaFileUpload(file_path, resumable=True, chunksize=chunksize)
files_api.create(body=file_metadata, media_body=media, fields="*", supportsTeamDrives=True).execute()
Stack trace
2020-05-02 23:31:14.093 | ERROR | mengy_gdrive:upload:394 - upload failed | File /home/ming_gdrive.py, line 392, in upload
381 def upload(self, file_path, remote_dir, chunksize=8 * 2 ** 20):
(...)
388 return False, None
389 file_metadata = {"name": file_name, "parents": [parent_id]}
390 media = MediaFileUpload(file_path, resumable=True, chunksize=chunksize)
391 try:
--> 392 result = self.files_api.create(body=file_metadata, media_body=media, fields="*", supportsTeamDrives=True).execute()
393 except Exception:
..................................................
self = <mengy_gdrive.GoogleDrive object at 0x7f126fcdf160>
file_path = '[ETest.zip'
remote_dir = ''
chunksize = 8388608
file_metadata = {'name': '[ETest.zip',
'parents': ['assea830sXQ8n44445', ]}
file_name = '[ETest.zip'
parent_id = 'assea830sXQ8n44445'
media = <googleapiclient.http.MediaFileUpload object at 0x7f126e2d66
a0>
MediaFileUpload = <class 'googleapiclient.http.MediaFileUpload'>
self.files_api.create = <method 'createMethod.<locals>.method' of <googleapiclient.d
iscovery.Resource object at 0x7f126fcdf400> discovery.py:750
>
..................................................
File /usr/local/lib/python3.6/dist-packages/googleapiclient/_helpers.py, line 134, in positional_wrapper
116 def positional_wrapper(*args, **kwargs):
(...)
130 if positional_parameters_enforcement == POSITIONAL_EXCEPTION:
131 raise TypeError(message)
132 elif positional_parameters_enforcement == POSITIONAL_WARNING:
133 logger.warning(message)
--> 134 return wrapped(*args, **kwargs)
..................................................
args = (<googleapiclient.http.HttpRequest object at 0x7f126f802080>
, )
kwargs = {}
positional_parameters_enforcement = 'WARNING'
POSITIONAL_EXCEPTION = 'EXCEPTION'
POSITIONAL_WARNING = 'WARNING'
logger.warning = <method 'Logger.warning' of <Logger googleapiclient._helpers
(WARNING)> __init__.py:1310>
wrapped = <function 'HttpRequest.execute' http.py:845>
..................................................
File /usr/local/lib/python3.6/dist-packages/googleapiclient/http.py, line 871, in execute
846 def execute(self, http=None, num_retries=0):
(...)
867
868 if self.resumable:
869 body = None
870 while body is None:
--> 871 _, body = self.next_chunk(http=http, num_retries=num_retries)
872 return body
..................................................
self = <googleapiclient.http.HttpRequest object at 0x7f126f802080>
http = <httplib2.Http object at 0x7f126fcdf1d0>
num_retries = 0
self.resumable = <googleapiclient.http.MediaFileUpload object at 0x7f126e2d66
a0>
body = None
self.next_chunk = <method 'HttpRequest.next_chunk' of <googleapiclient.http.Ht
tpRequest object at 0x7f126f802080> _helpers.py:115>
..................................................
File /usr/local/lib/python3.6/dist-packages/googleapiclient/_helpers.py, line 134, in positional_wrapper
116 def positional_wrapper(*args, **kwargs):
(...)
130 if positional_parameters_enforcement == POSITIONAL_EXCEPTION:
131 raise TypeError(message)
132 elif positional_parameters_enforcement == POSITIONAL_WARNING:
133 logger.warning(message)
--> 134 return wrapped(*args, **kwargs)
..................................................
args = (<googleapiclient.http.HttpRequest object at 0x7f126f802080>
, )
kwargs = {'http': <httplib2.Http object at 0x7f126fcdf1d0>,
'num_retries': 0}
positional_parameters_enforcement = 'WARNING'
POSITIONAL_EXCEPTION = 'EXCEPTION'
POSITIONAL_WARNING = 'WARNING'
logger.warning = <method 'Logger.warning' of <Logger googleapiclient._helpers
(WARNING)> __init__.py:1310>
wrapped = <function 'HttpRequest.next_chunk' http.py:922>
..................................................
File /usr/local/lib/python3.6/dist-packages/googleapiclient/http.py, line 1046, in next_chunk
923 def next_chunk(self, http=None, num_retries=0):
(...)
1042 )
1043
1044 try:
1045 resp, content = http.request(
--> 1046 self.resumable_uri, method="PUT", body=data, headers=headers
1047 )
..................................................
self = <googleapiclient.http.HttpRequest object at 0x7f126f802080>
http = <httplib2.Http object at 0x7f126fcdf1d0>
num_retries = 0
resp = Response
{'content-type': 'text/plain; charset=utf-8',
'x-guploader-uploadid': 'AAAAAAAAAAAAAA-7v4wbqsI
BBBBBBBBBBBB-CCCCCCCCCCCCCCCC',
'location': 'https://www.googleapis.com/upload/drive/v3/fil
es?fields=%2A&supportsTeamDrives=true&alt=json&uploadType=re
sumable&upload_id=AAAAAAAAAAAAAA-7v4wbqsI6PAdGsHO
z1QztW-CCCCCCCCCCCCCCCC',
'vary': 'Origin, X-Origin',
'cache-control': 'no-cache, no-store, max-age=0, must-reval
idat...
content = b''
http.request = <function 'wrap_http_for_auth.<locals>.new_request' transpor
t.py:153>
self.resumable_uri = 'https://www.googleapis.com/upload/drive/v3/files?fields=%2A
&supportsTeamDrives=true&alt=json&uploadType=resumable&uploa
d_id=AAAAAAAAAAAAAA-7v4wbqsIBBBBBBBBBBBB-gIghi_
qmOrFGN_fULjHyLppiNX3wgXq6Cca7PEDyG8'
data = <googleapiclient.http._StreamSlice object at 0x7f126f802048>
headers = {'Content-Range': 'bytes 0-8388607/19220531',
'Content-Length': '8388608'}
..................................................
File /usr/local/lib/python3.6/dist-packages/oauth2client/transport.py, line 175, in new_request
153 def new_request(uri, method='GET', body=None, headers=None,
154 redirections=httplib2.DEFAULT_MAX_REDIRECTS,
155 connection_type=None):
(...)
171 body_stream_position = body.tell()
172
173 resp, content = request(orig_request_method, uri, method, body,
174 clean_headers(headers),
--> 175 redirections, connection_type)
176
..................................................
uri = 'https://www.googleapis.com/upload/drive/v3/files?fields=%2A
&supportsTeamDrives=true&alt=json&uploadType=resumable&uploa
d_id=AAAAAAAAAAAAAA-7v4wbqsIBBBBBBBBBBBB-gIghi_
qmOrFGN_fULjHyLppiNX3wgXq6Cca7PEDyG8'
method = 'PUT'
body = <googleapiclient.http._StreamSlice object at 0x7f126f802048>
headers = {'Content-Range': 'bytes 0-8388607/19220531',
'Content-Length': '8388608',
'Authorization': 'Bearer ya29.asaaaaaaaaaaaaa
rVYCUuH5qpewb-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
ssssssssssssssssssss-psrsSGhlV393lhdhMgyyNNib4AL1VBH25EWR0dA
eeeeeeeeeeeeeeeeee'}
redirections = 5
httplib2.DEFAULT_MAX_REDIRECTS = 5
connection_type = None
body_stream_position = None
body.tell = # AttributeError
body = <googleapiclient.http._StreamSlice object at 0x7f126f
802048>
orig_request_method = <method 'Http.request' of <httplib2.Http object at 0x7f126fc
df1d0> __init__.py:1752>
..................................................
File /usr/local/lib/python3.6/dist-packages/oauth2client/transport.py, line 282, in request
254 def request(http, uri, method='GET', body=None, headers=None,
255 redirections=httplib2.DEFAULT_MAX_REDIRECTS,
256 connection_type=None):
(...)
278 # NOTE: Allowing http or http.request is temporary (See Issue 601).
279 http_callable = getattr(http, 'request', http)
280 return http_callable(uri, method=method, body=body, headers=headers,
281 redirections=redirections,
--> 282 connection_type=connection_type)
..................................................
http = <method 'Http.request' of <httplib2.Http object at 0x7f126fc
df1d0> __init__.py:1752>
uri = 'https://www.googleapis.com/upload/drive/v3/files?fields=%2A
&supportsTeamDrives=true&alt=json&uploadType=resumable&uploa
d_id=AAAAAAAAAAAAAA-7v4wbqsIBBBBBBBBBBBB-gIghi_
qmOrFGN_fULjHyLppiNX3wgXq6Cca7PEDyG8'
method = 'PUT'
body = <googleapiclient.http._StreamSlice object at 0x7f126f802048>
headers = {b'Content-Range': b'bytes 0-8388607/19220531',
b'Content-Length': b'8388608',
b'Authorization': b'Bearer ya29.a0Ae4lvC2s7m_AWRJWW9eyKPQXS
kJrVYCUuH5qpewb-0uQvTeBp81pBuFwNpVNajlCMhuVyAEeKEpbW8bteYPTS
ffssssssssssssssssssss-psrsSGhlV393lhdhMgyyNNib4AL1VBH25EWR0
dAeeeeeeeeeeeeeeeeee'}
redirections = 5
httplib2.DEFAULT_MAX_REDIRECTS = 5
connection_type = None
http_callable = <method 'Http.request' of <httplib2.Http object at 0x7f126fc
df1d0> __init__.py:1752>
..................................................
File /usr/local/lib/python3.6/dist-packages/httplib2/__init__.py, line 1991, in request
1752 def request(
1753 self,
1754 uri,
1755 method="GET",
1756 body=None,
1757 headers=None,
1758 redirections=DEFAULT_MAX_REDIRECTS,
1759 connection_type=None,
1760 ):
(...)
1987 method,
1988 body,
1989 headers,
1990 redirections,
--> 1991 cachekey,
1992 )
..................................................
self = <httplib2.Http object at 0x7f126fcdf1d0>
uri = 'https://www.googleapis.com/upload/drive/v3/files?fields=%2A
&supportsTeamDrives=true&alt=json&uploadType=resumable&uploa
d_id=AAAAAAAAAAAAAA-7v4wbqsIBBBBBBBBBBBB-gIghi_
qmOrFGN_fULjHyLppiNX3wgXq6Cca7PEDyG8'
method = 'PUT'
body = <googleapiclient.http._StreamSlice object at 0x7f126f802048>
headers = {'content-range': 'bytes 0-8388607/19220531',
'content-length': '8388608',
'authorization': 'Bearer ya29.asaaaaaaaaaaaaa
rVYCUuH5qpewb-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
ssssssssssssssssssss-psrsSGhlV393lhdhMgyyNNib4AL1VBH25EWR0dA
eeeeeeeeeeeeeeeeee',
'user-agent': 'Python-httplib2/0.17.3 (gzip)',
'accept-encoding': 'gzip, deflate'}
redirections = 5
DEFAULT_MAX_REDIRECTS = 5
connection_type = None
cachekey = None
..................................................
File /usr/local/lib/python3.6/dist-packages/httplib2/__init__.py, line 1690, in _request
1626 def _request(
1627 self,
1628 conn,
1629 host,
1630 absolute_uri,
1631 request_uri,
1632 method,
1633 body,
1634 headers,
1635 redirections,
1636 cachekey,
1637 ):
(...)
1686 _(
1687 "Redirected but the response is missing a Location: header."
1688 ),
1689 response,
--> 1690 content,
1691 )
..................................................
self = <httplib2.Http object at 0x7f126fcdf1d0>
conn = <httplib2.HTTPSConnectionWithTimeout object at 0x7f12756ca8d
0>
host = 'www.googleapis.com'
absolute_uri = 'https://www.googleapis.com/upload/drive/v3/files?fields=%2A
&supportsTeamDrives=true&alt=json&uploadType=resumable&uploa
d_id=AAAAAAAAAAAAAA-7v4wbqsIBBBBBBBBBBBB-gIghi_
qmOrFGN_fULjHyLppiNX3wgXq6Cca7PEDyG8'
request_uri = '/upload/drive/v3/files?fields=%2A&supportsTeamDrives=true&a
lt=json&uploadType=resumable&upload_id=AAANsUltTVE6HLnImO36O
7mya-7v4wbqsIBBBBBBBBBBBB-sssssssssssssssssssssssssssssssssss
Cca7PEDyG8'
method = 'PUT'
body = <googleapiclient.http._StreamSlice object at 0x7f126f802048>
headers = {'content-range': 'bytes 0-8388607/19220531',
'content-length': '8388608',
'authorization': 'Bearer ya29.asaaaaaaaaaaaaa
rVYCUuH5qpewb-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
ssssssssssssssssssss-psrsSGhlV393lhdhMgyyNNib4AL1VBH25EWR0dA
eeeeeeeeeeeeeeeeee',
'user-agent': 'Python-httplib2/0.17.3 (gzip)',
'accept-encoding': 'gzip, deflate'}
redirections = 5
cachekey = None
_ = <function 'gettext' gettext.py:626>
response = Response
{'content-type': 'text/plain; charset=utf-8',
'x-guploader-uploadid': 'AAAAAAAAAAAAAA-7v4wbqsI
BBBBBBBBBBBB-CCCCCCCCCCCCCCCC',
'range': 'bytes=0-8388607',
'x-range-md5': '066f22139bba2254574c7c9a967eadddd',
'content-length': '0',
'date': 'Sat, 02 May 2020 15:31:12 GMT',
'server': 'UploadServer',
'alt-svc': 'h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2
592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000
,h3-Q043=":443"; ma=2592000,qui...
content = b''
..................................................
---- (full traceback above) ----
File /home/ming_gdrive.py, line 392, in upload
result = self.files_api.create(body=file_metadata, media_body=media, fields="*", supportsTeamDrives=True).execute()
File /usr/local/lib/python3.6/dist-packages/googleapiclient/_helpers.py, line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File /usr/local/lib/python3.6/dist-packages/googleapiclient/http.py, line 871, in execute
_, body = self.next_chunk(http=http, num_retries=num_retries)
File /usr/local/lib/python3.6/dist-packages/googleapiclient/_helpers.py, line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File /usr/local/lib/python3.6/dist-packages/googleapiclient/http.py, line 1046, in next_chunk
self.resumable_uri, method="PUT", body=data, headers=headers
File /usr/local/lib/python3.6/dist-packages/oauth2client/transport.py, line 175, in new_request
redirections, connection_type)
File /usr/local/lib/python3.6/dist-packages/oauth2client/transport.py, line 282, in request
connection_type=connection_type)
File /usr/local/lib/python3.6/dist-packages/httplib2/__init__.py, line 1991, in request
cachekey,
File /usr/local/lib/python3.6/dist-packages/httplib2/__init__.py, line 1690, in _request
content,
RedirectMissingLocation: Redirected but the response is missing a Location: header.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
python - GCloud Upload httplib2.RedirectMissingLocation ...
RedirectMissingLocation : Redirected but the response is missing a Location: header. When I debug I see the below. { 'content-type': 'text/plain; ...
Read more >httplib2.RedirectMissingLocation: Redirected but the ...
RedirectMissingLocation: Redirected but the response is missing a Location: header. ... Apparently there is a breaking change in httplib2 .
Read more >1830874 – Duplicity with the pydrive backend fails with a " ...
Attempt 4 failed. RedirectMissingLocation: Redirected but the response is missing a Location: header. Giving up after 5 attempts.
Read more >RedirectMissingLocation('Redirected but the response is ...
RedirectMissingLocation ('Redirected but the response is missing a Location: header.',). So I have a bash script which uploads a bunch of ...
Read more >redirected but the response is missing a location: header.
Can be solved by installing previous version of httplib2 and google-api-python-client. 3. . 4. pip install httplib2==0.15.0.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m experiencing this error again with the google-api-python-client:
Name: httplib2 Version: 0.18.1 Summary: A comprehensive HTTP client library. Home-page: https://github.com/httplib2/httplib2 Author: Joe Gregorio Author-email: joe@bitworking.org License: MIT Location: /usr/local/lib/python3.8/dist-packages
Version: 1.10.0 Summary: Google API Client Library for Python Home-page: https://github.com/googleapis/google-api-python-client/ Author: Google LLC Author-email: googleapis-packages@google.com License: Apache 2.0 Location: /usr/local/lib/python3.8/dist-packages