Mercurial > hg > orthanc-stone
annotate Platforms/Generic/WebServicePostCommand.cpp @ 208:db70f6c5fa4f
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 11 Apr 2018 16:27:09 +0200 |
parents | e9c7a78a3e77 |
children | 5412adf19980 |
rev | line source |
---|---|
80 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
135
e2fe9352f240
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
123
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
80 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "WebServicePostCommand.h" | |
23 | |
201
e9c7a78a3e77
removed absolute paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
24 #include "../../Resources/Orthanc/Core/HttpClient.h" |
80 | 25 |
26 namespace OrthancStone | |
27 { | |
28 WebServicePostCommand::WebServicePostCommand(IWebService::ICallback& callback, | |
29 const Orthanc::WebServiceParameters& parameters, | |
30 const std::string& uri, | |
31 const std::string& body, | |
32 Orthanc::IDynamicObject* payload /* takes ownership */) : | |
33 callback_(callback), | |
34 parameters_(parameters), | |
35 uri_(uri), | |
36 body_(body), | |
37 payload_(payload) | |
38 { | |
39 } | |
40 | |
41 void WebServicePostCommand::Execute() | |
42 { | |
43 Orthanc::HttpClient client(parameters_, uri_); | |
123
ed0003f6102c
dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
44 client.SetTimeout(60); |
80 | 45 client.SetMethod(Orthanc::HttpMethod_Post); |
46 client.GetBody().swap(body_); | |
47 success_ = client.Apply(answer_); | |
48 } | |
49 | |
50 void WebServicePostCommand::Commit() | |
51 { | |
52 if (success_) | |
53 { | |
54 callback_.NotifySuccess(uri_, answer_.c_str(), answer_.size(), payload_.release()); | |
55 } | |
56 else | |
57 { | |
58 callback_.NotifyError(uri_, payload_.release()); | |
59 } | |
60 } | |
61 } |