Some methods don't specify a schema for their response, which means that
they are returning non-JSON such as CSV, images, etc. In that case
we return the bytes on the wire instead of trying to parse the response
as JSON.
Reviewed in http://codereview.appspot.com/5448123/
diff --git a/apiclient/model.py b/apiclient/model.py
index b8271f9..7f40efa 100644
--- a/apiclient/model.py
+++ b/apiclient/model.py
@@ -161,7 +161,8 @@
Returns:
The query parameters properly encoded into an HTTP URI query string.
"""
- params.update({'alt': self.alt_param})
+ if self.alt_param is not None:
+ params.update({'alt': self.alt_param})
astuples = []
for key, value in params.iteritems():
if type(value) == type([]):
@@ -269,6 +270,25 @@
return {}
+class RawModel(JsonModel):
+ """Model class for requests that don't return JSON.
+
+ Serializes and de-serializes between JSON and the Python
+ object representation of HTTP request, and returns the raw bytes
+ of the response body.
+ """
+ accept = '*/*'
+ content_type = 'application/json'
+ alt_param = None
+
+ def deserialize(self, content):
+ return content
+
+ @property
+ def no_content_response(self):
+ return ''
+
+
class ProtocolBufferModel(BaseModel):
"""Model class for protocol buffers.