Mercurial > hg > orthanc
annotate OrthancCppClient/HttpClient.h @ 469:a6fe16a31615
transmitting credentials by copy
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Jul 2013 15:36:59 +0200 |
parents | 456b9d2e9af4 |
children | c9a5d72f8481 |
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 |
400 | 3 * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, |
0 | 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_; | |
469
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
46 std::string credentials_; |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
47 Orthanc_HttpMethod method_; |
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
48 Orthanc_HttpStatus lastStatus_; |
0 | 49 std::string postData_; |
50 bool isVerbose_; | |
51 | |
469
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
52 void Setup(); |
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
53 |
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
54 void operator= (const HttpClient&); // Forbidden |
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
55 |
0 | 56 public: |
469
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
57 HttpClient(const HttpClient& base); |
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
58 |
0 | 59 HttpClient(); |
60 | |
61 ~HttpClient(); | |
62 | |
63 void SetUrl(const char* url) | |
64 { | |
65 url_ = std::string(url); | |
66 } | |
67 | |
68 void SetUrl(const std::string& url) | |
69 { | |
70 url_ = url; | |
71 } | |
72 | |
73 const std::string& GetUrl() const | |
74 { | |
75 return url_; | |
76 } | |
77 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
78 void SetMethod(Orthanc_HttpMethod method) |
0 | 79 { |
80 method_ = method; | |
81 } | |
82 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
83 Orthanc_HttpMethod GetMethod() const |
0 | 84 { |
85 return method_; | |
86 } | |
87 | |
88 std::string& AccessPostData() | |
89 { | |
90 return postData_; | |
91 } | |
92 | |
93 const std::string& AccessPostData() const | |
94 { | |
95 return postData_; | |
96 } | |
97 | |
98 void SetVerbose(bool isVerbose); | |
99 | |
100 bool IsVerbose() const | |
101 { | |
102 return isVerbose_; | |
103 } | |
104 | |
105 bool Apply(std::string& answer); | |
106 | |
107 bool Apply(Json::Value& answer); | |
108 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
109 Orthanc_HttpStatus GetLastStatus() const |
0 | 110 { |
111 return lastStatus_; | |
112 } | |
113 | |
114 const char* GetLastStatusText() const | |
115 { | |
116 return HttpException::GetDescription(lastStatus_); | |
117 } | |
118 | |
468
456b9d2e9af4
rename methods for clarity
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
457
diff
changeset
|
119 void SetCredentials(const char* username, |
456b9d2e9af4
rename methods for clarity
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
457
diff
changeset
|
120 const char* password); |
457 | 121 |
122 static void GlobalInitialize(); | |
123 | |
124 static void GlobalFinalize(); | |
0 | 125 }; |
126 } |