new commands: ns-op-list, ns-op-show, ns-action
[osm/osmclient.git] / osmclient / sol005 / http.py
index c89e91b..d76e41e 100644 (file)
@@ -50,13 +50,9 @@ class Http(http.Http):
         curl_cmd.close()
         # TODO 202 accepted should be returned somehow
         if data.getvalue():
-            return json.loads(data.getvalue().decode())
-        elif http_code == 404:
-            return "NOT FOUND"
-        elif http_code >= 300:
-            return "Failed"
+            return http_code, json.loads(data.getvalue().decode())
         else:
-            return
+            return http_code, None
 
     def send_cmd(self, endpoint='', postfields_dict=None,
                  formfile=None, filename=None,
@@ -124,6 +120,9 @@ class Http(http.Http):
         curl_cmd.setopt(pycurl.HTTPGET, 1)
         curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write)
         curl_cmd.perform()
+        http_code = curl_cmd.getinfo(pycurl.HTTP_CODE)
         curl_cmd.close()
-        return data.getvalue()
+        if data.getvalue():
+            return http_code, data.getvalue()
+        return http_code, None