Allow serialization impl to be overridden

Change-Id: I0f955c78897d4212f06942e59a7018dbe5d28540
This commit is contained in:
Dolph Mathews
2012-09-11 11:10:40 -05:00
parent 703c8b340c
commit e259597245

View File

@@ -107,6 +107,9 @@ class HTTPClient(httplib2.Http):
if self.debug_log:
_logger.debug("RESP: %s\nRESP BODY: %s\n", resp, body)
def serialize(self, entity):
return json.dumps(entity)
def request(self, url, method, **kwargs):
""" Send an http request with the specified characteristics.
@@ -119,7 +122,7 @@ class HTTPClient(httplib2.Http):
request_kwargs['headers']['User-Agent'] = self.USER_AGENT
if 'body' in kwargs:
request_kwargs['headers']['Content-Type'] = 'application/json'
request_kwargs['body'] = json.dumps(kwargs['body'])
request_kwargs['body'] = self.serialize(kwargs['body'])
self.http_log_req((url, method,), request_kwargs)
resp, body = super(HTTPClient, self).request(url,