comparison Core/HttpClient.h @ 2040:6ea2e264ca50

retrieval of HTTP headers in answers within HttpClient
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 Jun 2016 16:34:30 +0200
parents 7fe860db9664
children 9f61ca1e3eb3
comparison
equal deleted inserted replaced
2039:e33e0ae51d7b 2040:6ea2e264ca50
41 41
42 namespace Orthanc 42 namespace Orthanc
43 { 43 {
44 class HttpClient 44 class HttpClient
45 { 45 {
46 public:
47 typedef std::map<std::string, std::string> HttpHeaders;
48
46 private: 49 private:
47 class GlobalParameters; 50 class GlobalParameters;
48 51
49 struct PImpl; 52 struct PImpl;
50 boost::shared_ptr<PImpl> pimpl_; 53 boost::shared_ptr<PImpl> pimpl_;
67 void Setup(); 70 void Setup();
68 71
69 void operator= (const HttpClient&); // Assignment forbidden 72 void operator= (const HttpClient&); // Assignment forbidden
70 HttpClient(const HttpClient& base); // Copy forbidden 73 HttpClient(const HttpClient& base); // Copy forbidden
71 74
72 bool ApplyInternal(std::string& answer); 75 bool ApplyInternal(std::string& answer,
76 HttpHeaders* answerHeaders);
77
78 bool ApplyInternal(Json::Value& answer,
79 HttpHeaders* answerHeaders);
73 80
74 public: 81 public:
75 HttpClient(); 82 HttpClient();
76 83
77 HttpClient(const WebServiceParameters& service, 84 HttpClient(const WebServiceParameters& service,
139 void AddHeader(const std::string& key, 146 void AddHeader(const std::string& key,
140 const std::string& value); 147 const std::string& value);
141 148
142 void ClearHeaders(); 149 void ClearHeaders();
143 150
144 bool Apply(std::string& answer); 151 bool Apply(std::string& answer)
145 152 {
146 bool Apply(Json::Value& answer); 153 return ApplyInternal(answer, NULL);
154 }
155
156 bool Apply(Json::Value& answer)
157 {
158 return ApplyInternal(answer, NULL);
159 }
160
161 bool Apply(std::string& answer,
162 HttpHeaders& answerHeaders)
163 {
164 return ApplyInternal(answer, &answerHeaders);
165 }
166
167 bool Apply(Json::Value& answer,
168 HttpHeaders& answerHeaders)
169 {
170 return ApplyInternal(answer, &answerHeaders);
171 }
147 172
148 HttpStatus GetLastStatus() const 173 HttpStatus GetLastStatus() const
149 { 174 {
150 return lastStatus_; 175 return lastStatus_;
151 } 176 }