annotate OrthancFramework/Sources/HttpServer/IHttpHandler.cpp @ 4706:dbee8bd8ee1f

display OpenSSL version in the logs
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Jun 2021 09:13:03 +0200
parents c8f444e8556d
children 7053502fbf97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Lesser General Public License for more details.
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * License along with this program. If not, see
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>.
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "../PrecompiledHeaders.h"
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "IHttpHandler.h"
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "HttpOutput.h"
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "HttpToolbox.h"
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include "StringHttpOutput.h"
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 static const char* LOCALHOST = "127.0.0.1";
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace Orthanc
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
35 HttpStatus IHttpHandler::SimpleGet(std::string& answerBody,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
36 HttpToolbox::Arguments* answerHeaders,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
37 IHttpHandler& handler,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
38 RequestOrigin origin,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
39 const std::string& uri,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
40 const HttpToolbox::Arguments& httpHeaders)
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 UriComponents curi;
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
43 HttpToolbox::GetArguments getArguments;
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 HttpToolbox::ParseGetQuery(curi, getArguments, uri.c_str());
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 StringHttpOutput stream;
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 HttpOutput http(stream, false /* no keep alive */);
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 if (handler.Handle(http, origin, LOCALHOST, "", HttpMethod_Get, curi,
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 httpHeaders, getArguments, NULL /* no body for GET */, 0))
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
52 stream.GetBody(answerBody);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
53
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
54 if (answerHeaders != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
55 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
56 stream.GetHeaders(*answerHeaders, true /* convert key to lower case */);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
57 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
58
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
59 return stream.GetStatus();
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 else
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
63 return HttpStatus_404_NotFound;
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
68 static HttpStatus SimplePostOrPut(std::string& answerBody,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
69 HttpToolbox::Arguments* answerHeaders,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
70 IHttpHandler& handler,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
71 RequestOrigin origin,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
72 HttpMethod method,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
73 const std::string& uri,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
74 const void* bodyData,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
75 size_t bodySize,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
76 const HttpToolbox::Arguments& httpHeaders)
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 {
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
78 HttpToolbox::GetArguments getArguments; // No GET argument for POST/PUT
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 UriComponents curi;
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 Toolbox::SplitUriComponents(curi, uri);
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 StringHttpOutput stream;
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 HttpOutput http(stream, false /* no keep alive */);
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 if (handler.Handle(http, origin, LOCALHOST, "", method, curi,
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 httpHeaders, getArguments, bodyData, bodySize))
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
89 stream.GetBody(answerBody);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
90
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
91 if (answerHeaders != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
92 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
93 stream.GetHeaders(*answerHeaders, true /* convert key to lower case */);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
94 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
95
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
96 return stream.GetStatus();
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 else
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
100 return HttpStatus_404_NotFound;
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
105 HttpStatus IHttpHandler::SimplePost(std::string& answerBody,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
106 HttpToolbox::Arguments* answerHeaders,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
107 IHttpHandler& handler,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
108 RequestOrigin origin,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
109 const std::string& uri,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
110 const void* bodyData,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
111 size_t bodySize,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
112 const HttpToolbox::Arguments& httpHeaders)
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
114 return SimplePostOrPut(answerBody, answerHeaders, handler, origin, HttpMethod_Post, uri, bodyData, bodySize, httpHeaders);
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
118 HttpStatus IHttpHandler::SimplePut(std::string& answerBody,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
119 HttpToolbox::Arguments* answerHeaders,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
120 IHttpHandler& handler,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
121 RequestOrigin origin,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
122 const std::string& uri,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
123 const void* bodyData,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
124 size_t bodySize,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
125 const HttpToolbox::Arguments& httpHeaders)
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
127 return SimplePostOrPut(answerBody, answerHeaders, handler, origin, HttpMethod_Put, uri, bodyData, bodySize, httpHeaders);
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
131 HttpStatus IHttpHandler::SimpleDelete(HttpToolbox::Arguments* answerHeaders,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
132 IHttpHandler& handler,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
133 RequestOrigin origin,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
134 const std::string& uri,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
135 const HttpToolbox::Arguments& httpHeaders)
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 UriComponents curi;
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 Toolbox::SplitUriComponents(curi, uri);
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
140 HttpToolbox::GetArguments getArguments; // No GET argument for DELETE
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 StringHttpOutput stream;
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 HttpOutput http(stream, false /* no keep alive */);
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
145 if (handler.Handle(http, origin, LOCALHOST, "", HttpMethod_Delete, curi,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
146 httpHeaders, getArguments, NULL /* no body for DELETE */, 0))
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
147 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
148 if (answerHeaders != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
149 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
150 stream.GetHeaders(*answerHeaders, true /* convert key to lower case */);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
151 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
152
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
153 return stream.GetStatus();
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
154 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
155 else
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
156 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
157 return HttpStatus_404_NotFound;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
158 }
4329
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 }
9dc0e42f868b moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }