diff Core/HttpServer/HttpHandler.cpp @ 1437:02f5a3f5c0a0

access to the REST API from Lua
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Jun 2015 18:41:33 +0200
parents feaf2840917c
children
line wrap: on
line diff
--- a/Core/HttpServer/HttpHandler.cpp	Tue Jun 30 17:19:26 2015 +0200
+++ b/Core/HttpServer/HttpHandler.cpp	Tue Jun 30 18:41:33 2015 +0200
@@ -36,6 +36,9 @@
 #include <string.h>
 #include <iostream>
 
+#include "HttpOutput.h"
+#include "StringHttpOutput.h"
+
 
 namespace Orthanc
 {
@@ -188,4 +191,30 @@
       compiled[source[i].first] = source[i].second;
     }
   }
+
+
+  bool HttpHandler::SimpleGet(std::string& output,
+                              const std::string& uri)
+  {
+    Arguments headers;  // No HTTP header
+    std::string body;  // No body for a GET request
+
+    UriComponents curi;
+    GetArguments getArguments;
+    ParseGetQuery(curi, getArguments, uri.c_str());
+
+    StringHttpOutput stream;
+    HttpOutput http(stream, false /* no keep alive */);
+
+    if (Handle(http, HttpMethod_Get, curi, headers, getArguments, body))
+    {
+      stream.GetOutput(output);
+      return true;
+    }
+    else
+    {
+      return false;
+    }
+  }
+
 }