diff OrthancFramework/Sources/HttpServer/HttpToolbox.h @ 4330:a01b1c9cbef4

moving generic type definitions from IHttpHandler to HttpToolbox
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Nov 2020 14:39:10 +0100
parents 9dc0e42f868b
children 17d209a3f397
line wrap: on
line diff
--- a/OrthancFramework/Sources/HttpServer/HttpToolbox.h	Wed Nov 25 13:46:49 2020 +0100
+++ b/OrthancFramework/Sources/HttpServer/HttpToolbox.h	Wed Nov 25 14:39:10 2020 +0100
@@ -22,33 +22,86 @@
 
 #pragma once
 
+#if !defined(ORTHANC_SANDBOXED)
+#  error Macro ORTHANC_SANDBOXED must be defined
+#endif
+
+#include "../Compatibility.h"
 #include "../OrthancFramework.h"
-#include "IHttpHandler.h"
+#include "../Toolbox.h"
+
+#include <boost/noncopyable.hpp>
+#include <map>
+#include <vector>
 
 namespace Orthanc
 {
+  class IHttpHandler;
+  
   class ORTHANC_PUBLIC HttpToolbox : public boost::noncopyable
   {
   public:
-    static void ParseGetArguments(IHttpHandler::GetArguments& result, 
+    typedef std::map<std::string, std::string>                  Arguments;
+    typedef std::vector< std::pair<std::string, std::string> >  GetArguments;
+
+    static void ParseGetArguments(GetArguments& result, 
                                   const char* query);
 
     static void ParseGetQuery(UriComponents& uri,
-                              IHttpHandler::GetArguments& getArguments, 
+                              GetArguments& getArguments, 
                               const char* query);
 
-    static std::string GetArgument(const IHttpHandler::Arguments& getArguments,
+    static std::string GetArgument(const Arguments& getArguments,
+                                   const std::string& name,
+                                   const std::string& defaultValue);
+
+    static std::string GetArgument(const GetArguments& getArguments,
                                    const std::string& name,
                                    const std::string& defaultValue);
 
-    static std::string GetArgument(const IHttpHandler::GetArguments& getArguments,
-                                   const std::string& name,
-                                   const std::string& defaultValue);
+    static void ParseCookies(Arguments& result, 
+                             const Arguments& httpHeaders);
+
+    static void CompileGetArguments(Arguments& compiled,
+                                    const GetArguments& source);
 
-    static void ParseCookies(IHttpHandler::Arguments& result, 
-                             const IHttpHandler::Arguments& httpHeaders);
+#if ORTHANC_SANDBOXED != 1
+    ORTHANC_DEPRECATED
+    static bool SimpleGet(std::string& result,
+                          IHttpHandler& handler,
+                          RequestOrigin origin,
+                          const std::string& uri,
+                          const Arguments& httpHeaders);
+#endif
+    
+#if ORTHANC_SANDBOXED != 1
+    ORTHANC_DEPRECATED
+    static bool SimplePost(std::string& result,
+                           IHttpHandler& handler,
+                           RequestOrigin origin,
+                           const std::string& uri,
+                           const void* bodyData,
+                           size_t bodySize,
+                           const Arguments& httpHeaders);
+#endif
 
-    static void CompileGetArguments(IHttpHandler::Arguments& compiled,
-                                    const IHttpHandler::GetArguments& source);
+#if ORTHANC_SANDBOXED != 1
+    ORTHANC_DEPRECATED
+    static bool SimplePut(std::string& result,
+                          IHttpHandler& handler,
+                          RequestOrigin origin,
+                          const std::string& uri,
+                          const void* bodyData,
+                          size_t bodySize,
+                          const Arguments& httpHeaders);
+#endif
+
+#if ORTHANC_SANDBOXED != 1
+    ORTHANC_DEPRECATED
+    static bool SimpleDelete(IHttpHandler& handler,
+                             RequestOrigin origin,
+                             const std::string& uri,
+                             const Arguments& httpHeaders);
+#endif
   };
 }