X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fcommon%2FhttpClient.py;h=11c2d752dc043a301f303516459c9eca0ac5b11b;hb=f4093d1c2bd64ff53320e9f689d0cd77590bbcee;hp=ab2e9a37998577038585f91839511bdb05342b49;hpb=310eec58b65fdea6ded88f4271d93a8eaf7a599a;p=yardstick.git diff --git a/yardstick/common/httpClient.py b/yardstick/common/httpClient.py index ab2e9a379..11c2d752d 100644 --- a/yardstick/common/httpClient.py +++ b/yardstick/common/httpClient.py @@ -6,9 +6,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import json +from __future__ import absolute_import + import logging +from oslo_serialization import jsonutils import requests logger = logging.getLogger(__name__) @@ -17,7 +19,7 @@ logger = logging.getLogger(__name__) class HttpClient(object): def post(self, url, data): - data = json.dumps(data) + data = jsonutils.dump_as_bytes(data) headers = {'Content-Type': 'application/json'} try: response = requests.post(url, data=data, headers=headers) @@ -28,3 +30,7 @@ class HttpClient(object): except Exception as e: logger.debug('Failed: %s', e) raise + + def get(self, url): + response = requests.get(url) + return response.json()