Mercurial > hg > orthanc
annotate OrthancCppClient/HttpClient.h @ 121:a7e98bbeaf48 Orthanc-0.2.2
close
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 29 Apr 2013 12:54:48 +0200 |
parents | 77aec9be0a51 |
children | aa6c8a942952 |
rev | line source |
---|---|
0 | 1 /** |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
0 | 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, |
4 * Belgium | |
5 * | |
6 * Permission is hereby granted, free of charge, to any person | |
7 * obtaining a copy of this software and associated documentation | |
8 * files (the "Software"), to deal in the Software without | |
9 * restriction, including without limitation the rights to use, copy, | |
10 * modify, merge, publish, distribute, sublicense, and/or sell copies | |
11 * of the Software, and to permit persons to whom the Software is | |
12 * furnished to do so, subject to the following conditions: | |
13 * | |
14 * The above copyright notice and this permission notice shall be | |
15 * included in all copies or substantial portions of the Software. | |
16 * | |
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
24 * SOFTWARE. | |
25 **/ | |
26 | |
27 | |
28 #pragma once | |
29 | |
30 #include "HttpEnumerations.h" | |
31 #include "HttpException.h" | |
32 | |
33 #include <string> | |
34 #include <boost/shared_ptr.hpp> | |
35 #include <json/json.h> | |
36 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
37 namespace Orthanc |
0 | 38 { |
39 class HttpClient | |
40 { | |
41 private: | |
42 struct PImpl; | |
43 boost::shared_ptr<PImpl> pimpl_; | |
44 | |
45 std::string url_; | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
46 Orthanc_HttpMethod method_; |
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
47 Orthanc_HttpStatus lastStatus_; |
0 | 48 std::string postData_; |
49 bool isVerbose_; | |
50 | |
51 public: | |
52 HttpClient(); | |
53 | |
54 ~HttpClient(); | |
55 | |
56 void SetUrl(const char* url) | |
57 { | |
58 url_ = std::string(url); | |
59 } | |
60 | |
61 void SetUrl(const std::string& url) | |
62 { | |
63 url_ = url; | |
64 } | |
65 | |
66 const std::string& GetUrl() const | |
67 { | |
68 return url_; | |
69 } | |
70 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
71 void SetMethod(Orthanc_HttpMethod method) |
0 | 72 { |
73 method_ = method; | |
74 } | |
75 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
76 Orthanc_HttpMethod GetMethod() const |
0 | 77 { |
78 return method_; | |
79 } | |
80 | |
81 std::string& AccessPostData() | |
82 { | |
83 return postData_; | |
84 } | |
85 | |
86 const std::string& AccessPostData() const | |
87 { | |
88 return postData_; | |
89 } | |
90 | |
91 void SetVerbose(bool isVerbose); | |
92 | |
93 bool IsVerbose() const | |
94 { | |
95 return isVerbose_; | |
96 } | |
97 | |
98 bool Apply(std::string& answer); | |
99 | |
100 bool Apply(Json::Value& answer); | |
101 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
102 Orthanc_HttpStatus GetLastStatus() const |
0 | 103 { |
104 return lastStatus_; | |
105 } | |
106 | |
107 const char* GetLastStatusText() const | |
108 { | |
109 return HttpException::GetDescription(lastStatus_); | |
110 } | |
111 | |
112 }; | |
113 } |