osm.py fix bug in ns-action parameters, missing action_name
[osm/osmclient.git] / osmclient / sol005 / http.py
index 11ddca6..d76e41e 100644 (file)
@@ -48,16 +48,11 @@ class Http(http.Http):
         http_code = curl_cmd.getinfo(pycurl.HTTP_CODE)
         #print 'HTTP_CODE: {}'.format(http_code)
         curl_cmd.close()
-        if http_code == 204:
-            return None
-        elif http_code == 404:
-            if data.getvalue():
-                return json.loads(data.getvalue().decode())
-            else:
-                return "NOT FOUND"
+        # TODO 202 accepted should be returned somehow
         if data.getvalue():
-            return json.loads(data.getvalue().decode())
-        return "Failed"
+            return http_code, json.loads(data.getvalue().decode())
+        else:
+            return http_code, None
 
     def send_cmd(self, endpoint='', postfields_dict=None,
                  formfile=None, filename=None,
@@ -125,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