Mercurial > hg > orthanc
comparison OrthancFramework/Sources/HttpClient.cpp @ 4297:785a2713323e
abi continued
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 05 Nov 2020 17:20:49 +0100 |
parents | 2d5209153b32 |
children | 3af1d763763a |
comparison
equal
deleted
inserted
replaced
4296:3b70a2e6a06c | 4297:785a2713323e |
---|---|
675 HttpClient::~HttpClient() | 675 HttpClient::~HttpClient() |
676 { | 676 { |
677 curl_easy_cleanup(pimpl_->curl_); | 677 curl_easy_cleanup(pimpl_->curl_); |
678 } | 678 } |
679 | 679 |
680 void HttpClient::SetUrl(const char *url) | |
681 { | |
682 url_ = std::string(url); | |
683 } | |
684 | |
685 void HttpClient::SetUrl(const std::string &url) | |
686 { | |
687 url_ = url; | |
688 } | |
689 | |
690 const std::string &HttpClient::GetUrl() const | |
691 { | |
692 return url_; | |
693 } | |
694 | |
695 void HttpClient::SetMethod(HttpMethod method) | |
696 { | |
697 method_ = method; | |
698 } | |
699 | |
700 HttpMethod HttpClient::GetMethod() const | |
701 { | |
702 return method_; | |
703 } | |
704 | |
705 void HttpClient::SetTimeout(long seconds) | |
706 { | |
707 timeout_ = seconds; | |
708 } | |
709 | |
710 long HttpClient::GetTimeout() const | |
711 { | |
712 return timeout_; | |
713 } | |
714 | |
680 | 715 |
681 void HttpClient::SetBody(const std::string& data) | 716 void HttpClient::SetBody(const std::string& data) |
682 { | 717 { |
683 body_ = data; | 718 body_ = data; |
684 pimpl_->requestBody_.Clear(); | 719 pimpl_->requestBody_.Clear(); |
685 } | 720 } |
686 | 721 |
722 std::string &HttpClient::GetBody() | |
723 { | |
724 return body_; | |
725 } | |
726 | |
727 const std::string &HttpClient::GetBody() const | |
728 { | |
729 return body_; | |
730 } | |
731 | |
687 | 732 |
688 void HttpClient::SetBody(IRequestBody& body) | 733 void HttpClient::SetBody(IRequestBody& body) |
689 { | 734 { |
690 body_.clear(); | 735 body_.clear(); |
691 pimpl_->requestBody_.SetBody(body); | 736 pimpl_->requestBody_.SetBody(body); |
710 } | 755 } |
711 else | 756 else |
712 { | 757 { |
713 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_VERBOSE, 0)); | 758 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_VERBOSE, 0)); |
714 } | 759 } |
760 } | |
761 | |
762 bool HttpClient::IsVerbose() const | |
763 { | |
764 return isVerbose_; | |
715 } | 765 } |
716 | 766 |
717 | 767 |
718 void HttpClient::AddHeader(const std::string& key, | 768 void HttpClient::AddHeader(const std::string& key, |
719 const std::string& value) | 769 const std::string& value) |
1031 const char* password) | 1081 const char* password) |
1032 { | 1082 { |
1033 credentials_ = std::string(username) + ":" + std::string(password); | 1083 credentials_ = std::string(username) + ":" + std::string(password); |
1034 } | 1084 } |
1035 | 1085 |
1086 void HttpClient::SetProxy(const std::string &proxy) | |
1087 { | |
1088 proxy_ = proxy; | |
1089 } | |
1090 | |
1091 void HttpClient::SetHttpsVerifyPeers(bool verify) | |
1092 { | |
1093 verifyPeers_ = verify; | |
1094 } | |
1095 | |
1096 bool HttpClient::IsHttpsVerifyPeers() const | |
1097 { | |
1098 return verifyPeers_; | |
1099 } | |
1100 | |
1101 void HttpClient::SetHttpsCACertificates(const std::string &certificates) | |
1102 { | |
1103 caCertificates_ = certificates; | |
1104 } | |
1105 | |
1106 const std::string &HttpClient::GetHttpsCACertificates() const | |
1107 { | |
1108 return caCertificates_; | |
1109 } | |
1110 | |
1036 | 1111 |
1037 void HttpClient::ConfigureSsl(bool httpsVerifyPeers, | 1112 void HttpClient::ConfigureSsl(bool httpsVerifyPeers, |
1038 const std::string& httpsVerifyCertificates) | 1113 const std::string& httpsVerifyCertificates) |
1039 { | 1114 { |
1040 #if ORTHANC_ENABLE_SSL == 1 | 1115 #if ORTHANC_ENABLE_SSL == 1 |
1102 { | 1177 { |
1103 CurlAnswer wrapper(answer, headersToLowerCase_); | 1178 CurlAnswer wrapper(answer, headersToLowerCase_); |
1104 return ApplyInternal(wrapper); | 1179 return ApplyInternal(wrapper); |
1105 } | 1180 } |
1106 | 1181 |
1182 bool HttpClient::Apply(std::string &answerBody) | |
1183 { | |
1184 return ApplyInternal(answerBody, NULL); | |
1185 } | |
1186 | |
1187 bool HttpClient::Apply(Json::Value &answerBody) | |
1188 { | |
1189 return ApplyInternal(answerBody, NULL); | |
1190 } | |
1191 | |
1192 bool HttpClient::Apply(std::string &answerBody, | |
1193 HttpClient::HttpHeaders &answerHeaders) | |
1194 { | |
1195 return ApplyInternal(answerBody, &answerHeaders); | |
1196 } | |
1197 | |
1198 bool HttpClient::Apply(Json::Value &answerBody, | |
1199 HttpClient::HttpHeaders &answerHeaders) | |
1200 { | |
1201 return ApplyInternal(answerBody, &answerHeaders); | |
1202 } | |
1203 | |
1204 HttpStatus HttpClient::GetLastStatus() const | |
1205 { | |
1206 return lastStatus_; | |
1207 } | |
1208 | |
1107 | 1209 |
1108 void HttpClient::ApplyAndThrowException(IAnswer& answer) | 1210 void HttpClient::ApplyAndThrowException(IAnswer& answer) |
1109 { | 1211 { |
1110 CurlAnswer wrapper(answer, headersToLowerCase_); | 1212 CurlAnswer wrapper(answer, headersToLowerCase_); |
1111 | 1213 |
1177 } | 1279 } |
1178 | 1280 |
1179 clientCertificateFile_ = certificateFile; | 1281 clientCertificateFile_ = certificateFile; |
1180 clientCertificateKeyFile_ = certificateKeyFile; | 1282 clientCertificateKeyFile_ = certificateKeyFile; |
1181 clientCertificateKeyPassword_ = certificateKeyPassword; | 1283 clientCertificateKeyPassword_ = certificateKeyPassword; |
1284 } | |
1285 | |
1286 void HttpClient::SetPkcs11Enabled(bool enabled) | |
1287 { | |
1288 pkcs11Enabled_ = enabled; | |
1289 } | |
1290 | |
1291 bool HttpClient::IsPkcs11Enabled() const | |
1292 { | |
1293 return pkcs11Enabled_; | |
1294 } | |
1295 | |
1296 const std::string &HttpClient::GetClientCertificateFile() const | |
1297 { | |
1298 return clientCertificateFile_; | |
1299 } | |
1300 | |
1301 const std::string &HttpClient::GetClientCertificateKeyFile() const | |
1302 { | |
1303 return clientCertificateKeyFile_; | |
1304 } | |
1305 | |
1306 const std::string &HttpClient::GetClientCertificateKeyPassword() const | |
1307 { | |
1308 return clientCertificateKeyPassword_; | |
1309 } | |
1310 | |
1311 void HttpClient::SetConvertHeadersToLowerCase(bool lowerCase) | |
1312 { | |
1313 headersToLowerCase_ = lowerCase; | |
1314 } | |
1315 | |
1316 bool HttpClient::IsConvertHeadersToLowerCase() const | |
1317 { | |
1318 return headersToLowerCase_; | |
1319 } | |
1320 | |
1321 void HttpClient::SetRedirectionFollowed(bool follow) | |
1322 { | |
1323 redirectionFollowed_ = follow; | |
1324 } | |
1325 | |
1326 bool HttpClient::IsRedirectionFollowed() const | |
1327 { | |
1328 return redirectionFollowed_; | |
1182 } | 1329 } |
1183 | 1330 |
1184 | 1331 |
1185 void HttpClient::InitializePkcs11(const std::string& module, | 1332 void HttpClient::InitializePkcs11(const std::string& module, |
1186 const std::string& pin, | 1333 const std::string& pin, |