changeset 2795:f2e49b953e86

RestToolbox.DoRawGet
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Jul 2018 16:15:23 +0200
parents f790999a250a
children 4df3c64402ba
files Resources/Samples/Python/RestToolbox.py
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)