changeset 2974:5f64ecbdfcb4

merge
author am@osimis.io
date Thu, 06 Dec 2018 10:39:27 +0100
parents 9b734c3e1095 (diff) 4be6a2b46f1e (current diff)
children e62e296a5714
files
diffstat 2 files changed, 26 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Thu Dec 06 10:11:40 2018 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Thu Dec 06 10:39:27 2018 +0100
@@ -1152,7 +1152,10 @@
     }
     else
     {
-      answer.ToJson(result);
+      if (!answer.IsEmpty())
+      {
+        answer.ToJson(result);
+      }
       return true;
     }
   }
@@ -1172,7 +1175,10 @@
     }
     else
     {
-      answer.ToJson(result);
+      if (!answer.IsEmpty())
+      {
+        answer.ToJson(result);
+      }
       return true;
     }
   }
@@ -1202,7 +1208,10 @@
     }
     else
     {
-      answer.ToJson(result);
+      if (!answer.IsEmpty()) // i.e, on a PUT to metadata/..., orthand returns an empty response
+      {
+        answer.ToJson(result);
+      }
       return true;
     }
   }
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Thu Dec 06 10:11:40 2018 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Thu Dec 06 10:39:27 2018 +0100
@@ -140,6 +140,11 @@
       return buffer_.size;
     }
 
+    bool IsEmpty() const
+    {
+      return GetSize() == 0 || GetData() == NULL;
+    }
+
     void Clear();
 
     void ToString(std::string& target) const;
@@ -443,6 +448,15 @@
                        body.size(), applyPlugins);
   }
 
+  inline bool RestApiPost(Json::Value& result,
+                          const std::string& uri,
+                          const MemoryBuffer& body,
+                          bool applyPlugins)
+  {
+    return RestApiPost(result, uri, body.GetData(),
+                       body.GetSize(), applyPlugins);
+  }
+
   bool RestApiPut(Json::Value& result,
                   const std::string& uri,
                   const char* body,