Mercurial > hg > orthanc
annotate OrthancFramework/Sources/HttpServer/IHttpHandler.cpp @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
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 |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * 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
|
10 * 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
|
11 * 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
|
12 * 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
|
13 * |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * 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
|
15 * 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
|
16 * 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
|
17 * Lesser General Public License for more details. |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * 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
|
20 * 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
|
21 * <http://www.gnu.org/licenses/>. |
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 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../PrecompiledHeaders.h" |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "IHttpHandler.h" |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include "HttpOutput.h" |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include "HttpToolbox.h" |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #include "StringHttpOutput.h" |
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 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
|
33 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 namespace Orthanc |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 { |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
37 HttpStatus IHttpHandler::SimpleGet(std::string& answerBody, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
38 HttpToolbox::Arguments* answerHeaders, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
39 IHttpHandler& handler, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
40 RequestOrigin origin, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
41 const std::string& uri, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
42 const HttpToolbox::Arguments& httpHeaders) |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 UriComponents curi; |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
45 HttpToolbox::GetArguments getArguments; |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 HttpToolbox::ParseGetQuery(curi, getArguments, uri.c_str()); |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 StringHttpOutput stream; |
5119
bdec57f3cbf2
New configuration KeepAliveTimeout with a default value of 1 second
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
49 HttpOutput http(stream, false /* assume no keep-alive */, 0); |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 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
|
52 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
|
53 { |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
54 stream.GetBody(answerBody); |
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 if (answerHeaders != NULL) |
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 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
|
59 } |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
60 |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
61 return stream.GetStatus(); |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 } |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 else |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 { |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
65 return HttpStatus_404_NotFound; |
4329
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 } |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
70 static HttpStatus SimplePostOrPut(std::string& answerBody, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
71 HttpToolbox::Arguments* answerHeaders, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
72 IHttpHandler& handler, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
73 RequestOrigin origin, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
74 HttpMethod method, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
75 const std::string& uri, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
76 const void* bodyData, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
77 size_t bodySize, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
78 const HttpToolbox::Arguments& httpHeaders) |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 { |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
80 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
|
81 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 UriComponents curi; |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 Toolbox::SplitUriComponents(curi, uri); |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 StringHttpOutput stream; |
5119
bdec57f3cbf2
New configuration KeepAliveTimeout with a default value of 1 second
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
86 HttpOutput http(stream, false /* assume no keep-alive */, 0); |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 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
|
89 httpHeaders, getArguments, bodyData, bodySize)) |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 { |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
91 stream.GetBody(answerBody); |
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 if (answerHeaders != NULL) |
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 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
|
96 } |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
97 |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
98 return stream.GetStatus(); |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 } |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 else |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 { |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
102 return HttpStatus_404_NotFound; |
4329
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 } |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
107 HttpStatus IHttpHandler::SimplePost(std::string& answerBody, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
108 HttpToolbox::Arguments* answerHeaders, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
109 IHttpHandler& handler, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
110 RequestOrigin origin, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
111 const std::string& uri, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
112 const void* bodyData, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
113 size_t bodySize, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
114 const HttpToolbox::Arguments& httpHeaders) |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 { |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
116 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
|
117 } |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
120 HttpStatus IHttpHandler::SimplePut(std::string& answerBody, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
121 HttpToolbox::Arguments* answerHeaders, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
122 IHttpHandler& handler, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
123 RequestOrigin origin, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
124 const std::string& uri, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
125 const void* bodyData, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
126 size_t bodySize, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
127 const HttpToolbox::Arguments& httpHeaders) |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 { |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
129 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
|
130 } |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
133 HttpStatus IHttpHandler::SimpleDelete(HttpToolbox::Arguments* answerHeaders, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
134 IHttpHandler& handler, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
135 RequestOrigin origin, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
136 const std::string& uri, |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
137 const HttpToolbox::Arguments& httpHeaders) |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 { |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 UriComponents curi; |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 Toolbox::SplitUriComponents(curi, uri); |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
142 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
|
143 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 StringHttpOutput stream; |
5119
bdec57f3cbf2
New configuration KeepAliveTimeout with a default value of 1 second
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
145 HttpOutput http(stream, false /* assume no keep-alive */, 0); |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 |
4605
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
147 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
|
148 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
|
149 { |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
150 if (answerHeaders != NULL) |
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 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
|
153 } |
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 return stream.GetStatus(); |
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 else |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
158 { |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
159 return HttpStatus_404_NotFound; |
c8f444e8556d
new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
160 } |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 } |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 } |