Allow serialization impl to be overridden
Change-Id: I0f955c78897d4212f06942e59a7018dbe5d28540
This commit is contained in:
@@ -107,6 +107,9 @@ class HTTPClient(httplib2.Http):
|
|||||||
if self.debug_log:
|
if self.debug_log:
|
||||||
_logger.debug("RESP: %s\nRESP BODY: %s\n", resp, body)
|
_logger.debug("RESP: %s\nRESP BODY: %s\n", resp, body)
|
||||||
|
|
||||||
|
def serialize(self, entity):
|
||||||
|
return json.dumps(entity)
|
||||||
|
|
||||||
def request(self, url, method, **kwargs):
|
def request(self, url, method, **kwargs):
|
||||||
""" Send an http request with the specified characteristics.
|
""" Send an http request with the specified characteristics.
|
||||||
|
|
||||||
@@ -119,7 +122,7 @@ class HTTPClient(httplib2.Http):
|
|||||||
request_kwargs['headers']['User-Agent'] = self.USER_AGENT
|
request_kwargs['headers']['User-Agent'] = self.USER_AGENT
|
||||||
if 'body' in kwargs:
|
if 'body' in kwargs:
|
||||||
request_kwargs['headers']['Content-Type'] = 'application/json'
|
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)
|
self.http_log_req((url, method,), request_kwargs)
|
||||||
resp, body = super(HTTPClient, self).request(url,
|
resp, body = super(HTTPClient, self).request(url,
|
||||||
|
Reference in New Issue
Block a user