diff OrthancServer/OrthancHttpHandler.cpp @ 3395:0ce9b4f5fdf5

new abstraction: IHttpHandler::CreateStreamHandler()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Jun 2019 18:54:27 +0200
parents 4e43e67f8ecf
children 962e5f00744b
line wrap: on
line diff
--- a/OrthancServer/OrthancHttpHandler.cpp	Thu Jun 06 16:42:41 2019 +0200
+++ b/OrthancServer/OrthancHttpHandler.cpp	Thu Jun 06 18:54:27 2019 +0200
@@ -39,6 +39,28 @@
 
 namespace Orthanc
 {
+  IHttpHandler::IStream* OrthancHttpHandler::CreateStreamHandler(RequestOrigin origin,
+                                                                 const char* remoteIp,
+                                                                 const char* username,
+                                                                 HttpMethod method,
+                                                                 const UriComponents& uri,
+                                                                 const Arguments& headers)
+  {
+    for (Handlers::const_iterator it = handlers_.begin(); it != handlers_.end(); ++it) 
+    {
+      IHttpHandler::IStream* stream = (*it)->CreateStreamHandler(
+        origin, remoteIp, username, method, uri, headers);
+
+      if (stream != NULL)
+      {
+        return stream;
+      }
+    }
+
+    return NULL;
+  }
+
+
   bool OrthancHttpHandler::Handle(HttpOutput& output,
                                   RequestOrigin origin,
                                   const char* remoteIp,
@@ -50,16 +72,16 @@
                                   const char* bodyData,
                                   size_t bodySize)
   {
-    bool found = false;
-
-    for (Handlers::const_iterator it = handlers_.begin(); 
-         it != handlers_.end() && !found; ++it) 
+    for (Handlers::const_iterator it = handlers_.begin(); it != handlers_.end(); ++it) 
     {
-      found = (*it)->Handle(output, origin, remoteIp, username, method, uri, 
-                            headers, getArguments, bodyData, bodySize);
+      if ((*it)->Handle(output, origin, remoteIp, username, method, uri, 
+                        headers, getArguments, bodyData, bodySize))
+      {
+        return true;
+      }
     }
 
-    return found;
+    return false;
   }