diff Plugins/Engine/OrthancPlugins.cpp @ 1882:5cf2bd0abfa2

OrthancPluginSendMultipartItem2 for DICOMweb
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Dec 2015 09:29:05 +0100
parents a7bea843a7bc
children b1291df2f780
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPlugins.cpp	Tue Dec 08 15:53:35 2015 +0100
+++ b/Plugins/Engine/OrthancPlugins.cpp	Wed Dec 09 09:29:05 2015 +0100
@@ -1574,7 +1574,39 @@
 
     *(p.target) = ReturnImage(result);
   }
-        
+
+
+  void OrthancPlugins::ApplySendMultipartItem(const void* parameters)
+  {
+    // An exception might be raised in this function if the
+    // connection was closed by the HTTP client.
+    const _OrthancPluginAnswerBuffer& p =
+      *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
+
+    HttpOutput* output = reinterpret_cast<HttpOutput*>(p.output);
+
+    std::map<std::string, std::string> headers;  // No custom headers
+    output->SendMultipartItem(p.answer, p.answerSize, headers);
+  }
+
+
+  void OrthancPlugins::ApplySendMultipartItem2(const void* parameters)
+  {
+    // An exception might be raised in this function if the
+    // connection was closed by the HTTP client.
+    const _OrthancPluginSendMultipartItem2& p =
+      *reinterpret_cast<const _OrthancPluginSendMultipartItem2*>(parameters);
+    HttpOutput* output = reinterpret_cast<HttpOutput*>(p.output);
+    
+    std::map<std::string, std::string> headers;
+    for (uint32_t i = 0; i < p.headersCount; i++)
+    {
+      headers[p.headersKeys[i]] = p.headersValues[i];
+    }
+    
+    output->SendMultipartItem(p.answer, p.answerSize, headers);
+  }
+      
 
   void OrthancPlugins::DatabaseAnswer(const void* parameters)
   {
@@ -1969,15 +2001,12 @@
       }
 
       case _OrthancPluginService_SendMultipartItem:
-      {
-        // An exception might be raised in this function if the
-        // connection was closed by the HTTP client.
-        const _OrthancPluginAnswerBuffer& p =
-          *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
-        HttpOutput* output = reinterpret_cast<HttpOutput*>(p.output);
-        output->SendMultipartItem(p.answer, p.answerSize);
+        ApplySendMultipartItem(parameters);
         return true;
-      }
+
+      case _OrthancPluginService_SendMultipartItem2:
+        ApplySendMultipartItem2(parameters);
+        return true;
 
       case _OrthancPluginService_ReadFile:
       {