annotate Framework/Oracle/HttpCommand.h @ 1205:6009c59d8676 broker

fix to sdl
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Dec 2019 14:32:05 +0100
parents a0a33e5ea5bb
children 0ca50d275b9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../Messages/IMessage.h"
1128
8e3763d1736a removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1079
diff changeset
25 #include "OracleCommandBase.h"
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <Core/Enumerations.h>
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <map>
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <json/value.h>
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace OrthancStone
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
1128
8e3763d1736a removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1079
diff changeset
34 class HttpCommand : public OracleCommandBase
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 public:
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 typedef std::map<std::string, std::string> HttpHeaders;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
1135
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
39 class SuccessMessage : public OriginMessage<HttpCommand>
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 private:
1134
87fbeb823375 allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1128
diff changeset
44 const HttpHeaders& headers_;
87fbeb823375 allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1128
diff changeset
45 const std::string& answer_;
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 public:
1135
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
48 SuccessMessage(const HttpCommand& command,
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 const HttpHeaders& answerHeaders,
1135
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
50 const std::string& answer) :
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
51 OriginMessage(command),
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
52 headers_(answerHeaders),
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
53 answer_(answer)
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
54 {
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
55 }
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 const std::string& GetAnswer() const
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 return answer_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 void ParseJsonBody(Json::Value& target) const;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
1134
87fbeb823375 allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1128
diff changeset
64 const HttpHeaders& GetAnswerHeaders() const
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 return headers_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 };
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 private:
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 Orthanc::HttpMethod method_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 std::string url_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 std::string body_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 HttpHeaders headers_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 unsigned int timeout_;
1079
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
77 std::string username_;
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
78 std::string password_;
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
1135
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
80 HttpCommand(const HttpCommand& other) :
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
81 method_(other.method_),
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
82 url_(other.url_),
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
83 body_(other.body_),
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
84 headers_(other.headers_),
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
85 timeout_(other.timeout_),
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
86 username_(other.username_),
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
87 password_(other.password_)
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
88 {
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
89 }
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
90
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 public:
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 HttpCommand();
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 virtual Type GetType() const
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 return Type_Http;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
1135
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
99 virtual IOracleCommand* Clone() const
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
100 {
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
101 return new HttpCommand(*this);
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
102 }
a0a33e5ea5bb IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
103
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 void SetMethod(Orthanc::HttpMethod method)
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 method_ = method;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 void SetUrl(const std::string& url)
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 url_ = url;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 void SetBody(const std::string& body)
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 body_ = body;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 void SetBody(const Json::Value& json);
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 void SwapBody(std::string& body)
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 body_.swap(body);
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 void SetHttpHeaders(const HttpHeaders& headers)
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 headers_ = headers;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 void SetHttpHeader(const std::string& key,
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 const std::string& value)
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 headers_[key] = value;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 Orthanc::HttpMethod GetMethod() const
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 return method_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 const std::string& GetUrl() const
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 return url_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 const std::string& GetBody() const;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 const HttpHeaders& GetHttpHeaders() const
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 return headers_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 void SetTimeout(unsigned int seconds)
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 timeout_ = seconds;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 unsigned int GetTimeout() const
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 {
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 return timeout_;
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
1079
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
163
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
164 void SetCredentials(const std::string& username,
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
165 const std::string& password)
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
166 {
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
167 username_ = username;
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
168 password_ = password;
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
169 }
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
170
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
171 void ClearCredentials()
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
172 {
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
173 username_.clear();
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
174 password_.clear();
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
175 }
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
176
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
177 bool HasCredentials() const
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
178 {
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
179 return !username_.empty();
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
180 }
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
181
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
182 const std::string& GetUsername() const;
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
183
e6d2ff8f1ab4 credentials in HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 979
diff changeset
184 const std::string& GetPassword() const;
979
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 };
18d53a8b41b7 HttpCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }