# HG changeset patch # User Sebastien Jodogne # Date 1532700923 -7200 # Node ID f2e49b953e86c6958b8a28e844c067fec5117af6 # Parent f790999a250a0380bdc623a4e2d5763d4c2b1c79 RestToolbox.DoRawGet diff -r f790999a250a -r f2e49b953e86 Resources/Samples/Python/RestToolbox.py --- a/Resources/Samples/Python/RestToolbox.py Fri Jul 27 14:01:02 2018 +0200 +++ b/Resources/Samples/Python/RestToolbox.py Fri Jul 27 16:15:23 2018 +0200 @@ -49,14 +49,17 @@ if _credentials != None: h.add_credentials(_credentials[0], _credentials[1]) -def DoGet(uri, data = {}, interpretAsJson = True): +def _ComputeGetUri(uri, data): d = '' if len(data.keys()) > 0: d = '?' + urlencode(data) + return uri + d + +def DoGet(uri, data = {}, interpretAsJson = True): h = httplib2.Http() _SetupCredentials(h) - resp, content = h.request(uri + d, 'GET') + resp, content = h.request(_ComputeGetUri(uri, data), 'GET') if not (resp.status in [ 200 ]): raise Exception(resp.status) elif not interpretAsJson: @@ -65,6 +68,16 @@ return _DecodeJson(content) +def DoRawGet(uri, data = {}): + h = httplib2.Http() + _SetupCredentials(h) + resp, content = h.request(_ComputeGetUri(uri, data), 'GET') + if not (resp.status in [ 200 ]): + raise Exception(resp.status) + else: + return content + + def _DoPutOrPost(uri, method, data, contentType): h = httplib2.Http() _SetupCredentials(h)