changeset 424:bb573a52fc63 am-vsol-upgrade

allow POST messages with success and failure handlers
author am@osimis.io
date Wed, 21 Nov 2018 17:08:03 +0100
parents 574fc54056af
children 087237703d63
files Framework/Toolbox/OrthancApiClient.cpp Framework/Toolbox/OrthancApiClient.h
diffstat 2 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Toolbox/OrthancApiClient.cpp	Wed Nov 21 17:07:43 2018 +0100
+++ b/Framework/Toolbox/OrthancApiClient.cpp	Wed Nov 21 17:08:03 2018 +0100
@@ -337,7 +337,13 @@
 
   }
 
-  
+  void OrthancApiClient::PostBinaryAsync(
+      const std::string& uri,
+      const std::string& body)
+  {
+    web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body, NULL, NULL, NULL);
+  }
+
   void OrthancApiClient::PostJsonAsyncExpectJson(
       const std::string& uri,
       const Json::Value& data,
@@ -350,7 +356,15 @@
     return PostBinaryAsyncExpectJson(uri, body, successCallback, failureCallback, payload);
   }
 
-  
+  void OrthancApiClient::PostJsonAsync(
+      const std::string& uri,
+      const Json::Value& data)
+  {
+    std::string body;
+    MessagingToolbox::JsonToString(body, data);
+    return PostBinaryAsync(uri, body);
+  }
+
   void OrthancApiClient::DeleteAsync(
       const std::string& uri,
       MessageHandler<EmptyResponseReadyMessage>* successCallback,
--- a/Framework/Toolbox/OrthancApiClient.h	Wed Nov 21 17:07:43 2018 +0100
+++ b/Framework/Toolbox/OrthancApiClient.h	Wed Nov 21 17:08:03 2018 +0100
@@ -205,6 +205,14 @@
                                  MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
                                  Orthanc::IDynamicObject* payload = NULL   /* takes ownership */);
 
+    // schedule a POST request and don't mind the response.
+    void PostJsonAsync(const std::string& uri,
+                       const Json::Value& data);
+
+    // schedule a POST request and don't mind the response.
+    void PostBinaryAsync(const std::string& uri,
+                         const std::string& body);
+
     // schedule a DELETE request expecting an empty response.
     void DeleteAsync(const std::string& uri,
                      MessageHandler<EmptyResponseReadyMessage>* successCallback,