Mercurial > hg > orthanc
annotate OrthancCppClient/HttpClient.h @ 474:a9693dc7089c
move tostring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Jul 2013 17:25:53 +0200 |
parents | c9a5d72f8481 |
children | 72cca077abf8 |
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 "HttpException.h" | |
31 | |
474 | 32 #include "../Core/Toolbox.h" |
33 | |
0 | 34 #include <string> |
35 #include <boost/shared_ptr.hpp> | |
36 #include <json/json.h> | |
37 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
38 namespace Orthanc |
0 | 39 { |
40 class HttpClient | |
41 { | |
42 private: | |
43 struct PImpl; | |
44 boost::shared_ptr<PImpl> pimpl_; | |
45 | |
46 std::string url_; | |
469
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
47 std::string credentials_; |
473
c9a5d72f8481
changing the namespace of HTTP enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
469
diff
changeset
|
48 HttpMethod method_; |
c9a5d72f8481
changing the namespace of HTTP enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
469
diff
changeset
|
49 HttpStatus lastStatus_; |
0 | 50 std::string postData_; |
51 bool isVerbose_; | |
52 | |
469
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
53 void Setup(); |
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
54 |
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
55 void operator= (const HttpClient&); // Forbidden |
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
56 |
0 | 57 public: |
469
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
58 HttpClient(const HttpClient& base); |
a6fe16a31615
transmitting credentials by copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
468
diff
changeset
|
59 |
0 | 60 HttpClient(); |
61 | |
62 ~HttpClient(); | |
63 | |
64 void SetUrl(const char* url) | |
65 { | |
66 url_ = std::string(url); | |
67 } | |
68 | |
69 void SetUrl(const std::string& url) | |
70 { | |
71 url_ = url; | |
72 } | |
73 | |
74 const std::string& GetUrl() const | |
75 { | |
76 return url_; | |
77 } | |
78 | |
473
c9a5d72f8481
changing the namespace of HTTP enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
469
diff
changeset
|
79 void SetMethod(HttpMethod method) |
0 | 80 { |
81 method_ = method; | |
82 } | |
83 | |
473
c9a5d72f8481
changing the namespace of HTTP enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
469
diff
changeset
|
84 HttpMethod GetMethod() const |
0 | 85 { |
86 return method_; | |
87 } | |
88 | |
89 std::string& AccessPostData() | |
90 { | |
91 return postData_; | |
92 } | |
93 | |
94 const std::string& AccessPostData() const | |
95 { | |
96 return postData_; | |
97 } | |
98 | |
99 void SetVerbose(bool isVerbose); | |
100 | |
101 bool IsVerbose() const | |
102 { | |
103 return isVerbose_; | |
104 } | |
105 | |
106 bool Apply(std::string& answer); | |
107 | |
108 bool Apply(Json::Value& answer); | |
109 | |
473
c9a5d72f8481
changing the namespace of HTTP enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
469
diff
changeset
|
110 HttpStatus GetLastStatus() const |
0 | 111 { |
112 return lastStatus_; | |
113 } | |
114 | |
115 const char* GetLastStatusText() const | |
116 { | |
474 | 117 return Toolbox::ToString(lastStatus_); |
0 | 118 } |
119 | |
468
456b9d2e9af4
rename methods for clarity
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
457
diff
changeset
|
120 void SetCredentials(const char* username, |
456b9d2e9af4
rename methods for clarity
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
457
diff
changeset
|
121 const char* password); |
457 | 122 |
123 static void GlobalInitialize(); | |
124 | |
125 static void GlobalFinalize(); | |
0 | 126 }; |
127 } |