Mercurial > hg > orthanc-stone
annotate Platforms/Generic/WebServiceGetCommand.cpp @ 113:2eca030792aa wasm
using the Orthanc Framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 20 Sep 2017 15:32:32 +0200 |
parents | f40a78cc7070 |
children | ed0003f6102c |
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 | |
5 * Copyright (C) 2017 Osimis, Belgium | |
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 "WebServiceGetCommand.h" | |
23 | |
113
2eca030792aa
using the Orthanc Framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
80
diff
changeset
|
24 #include <Core/HttpClient.h> |
80 | 25 |
26 namespace OrthancStone | |
27 { | |
28 WebServiceGetCommand::WebServiceGetCommand(IWebService::ICallback& callback, | |
29 const Orthanc::WebServiceParameters& parameters, | |
30 const std::string& uri, | |
31 Orthanc::IDynamicObject* payload /* takes ownership */) : | |
32 callback_(callback), | |
33 parameters_(parameters), | |
34 uri_(uri), | |
35 payload_(payload) | |
36 { | |
37 } | |
38 | |
39 | |
40 void WebServiceGetCommand::Execute() | |
41 { | |
42 Orthanc::HttpClient client(parameters_, uri_); | |
43 client.SetMethod(Orthanc::HttpMethod_Get); | |
44 success_ = client.Apply(answer_); | |
45 } | |
46 | |
47 | |
48 void WebServiceGetCommand::Commit() | |
49 { | |
50 if (success_) | |
51 { | |
52 callback_.NotifySuccess(uri_, answer_.c_str(), answer_.size(), payload_.release()); | |
53 } | |
54 else | |
55 { | |
56 callback_.NotifyError(uri_, payload_.release()); | |
57 } | |
58 } | |
59 } |