Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1436:0a3e3be59094 | 1437:02f5a3f5c0a0 |
---|---|
34 #include "HttpHandler.h" | 34 #include "HttpHandler.h" |
35 | 35 |
36 #include <string.h> | 36 #include <string.h> |
37 #include <iostream> | 37 #include <iostream> |
38 | 38 |
39 #include "HttpOutput.h" | |
40 #include "StringHttpOutput.h" | |
41 | |
39 | 42 |
40 namespace Orthanc | 43 namespace Orthanc |
41 { | 44 { |
42 static void SplitGETNameValue(HttpHandler::GetArguments& result, | 45 static void SplitGETNameValue(HttpHandler::GetArguments& result, |
43 const char* start, | 46 const char* start, |
186 for (size_t i = 0; i < source.size(); i++) | 189 for (size_t i = 0; i < source.size(); i++) |
187 { | 190 { |
188 compiled[source[i].first] = source[i].second; | 191 compiled[source[i].first] = source[i].second; |
189 } | 192 } |
190 } | 193 } |
194 | |
195 | |
196 bool HttpHandler::SimpleGet(std::string& output, | |
197 const std::string& uri) | |
198 { | |
199 Arguments headers; // No HTTP header | |
200 std::string body; // No body for a GET request | |
201 | |
202 UriComponents curi; | |
203 GetArguments getArguments; | |
204 ParseGetQuery(curi, getArguments, uri.c_str()); | |
205 | |
206 StringHttpOutput stream; | |
207 HttpOutput http(stream, false /* no keep alive */); | |
208 | |
209 if (Handle(http, HttpMethod_Get, curi, headers, getArguments, body)) | |
210 { | |
211 stream.GetOutput(output); | |
212 return true; | |
213 } | |
214 else | |
215 { | |
216 return false; | |
217 } | |
218 } | |
219 | |
191 } | 220 } |