google-code-export / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
1 stars 0 forks source link

MediaIoBaseDownload.download uses httpMethod GET rather than the request's httpMethod. #241

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. run the following code (with names replace with real service, collection and 
method names, where customverb uses POST):
request = someservice.somecollection().customverb_media()
fh = io.BytesIO()
downloader = apiclient.http.MediaIoBaseDownload(fh, request)
done = False
while done is False:
  unused_status, done = downloader.next_chunk()

What is the expected output? What do you see instead?
The expected request to the server uses POST, but the actual request is a GET 
and the server responds with a 404.

What version of the product are you using? On what operating system?
1.0 on Ubuntu Precise.

Please provide any additional information below.
If you have a method that supports media download but doesn't use the GET verb 
(e.g., it's a custom method that uses POST), and if you use MediaIoBaseDownload 
to execute the request, you get a 400 result because it doesn't match the 
method because MediaIoBaseDownload uniformly uses GET. If you used 
request.execute() directly, it would issue the POST correctly.

https://code.google.com/p/google-api-python-client/source/browse/apiclient/http.
py#528 appears to be the place where you'd want to use 
method=self._request.method in the construction of the download request chunk.

Original issue reported on code.google.com by nherr...@google.com on 22 Feb 2013 at 7:45