mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-19 03:57:14 +01:00
Update CPR.
This commit is contained in:
parent
425b13afe0
commit
a152fd2600
2
vendor/CPR/CMakeLists.txt
vendored
2
vendor/CPR/CMakeLists.txt
vendored
@ -12,6 +12,7 @@ add_library(CPR STATIC
|
|||||||
cpr/parameters.cpp
|
cpr/parameters.cpp
|
||||||
cpr/payload.cpp
|
cpr/payload.cpp
|
||||||
cpr/proxies.cpp
|
cpr/proxies.cpp
|
||||||
|
cpr/proxyauth.cpp
|
||||||
cpr/session.cpp
|
cpr/session.cpp
|
||||||
cpr/timeout.cpp
|
cpr/timeout.cpp
|
||||||
cpr/unix_socket.cpp
|
cpr/unix_socket.cpp
|
||||||
@ -36,6 +37,7 @@ add_library(CPR STATIC
|
|||||||
include/cpr/parameters.h
|
include/cpr/parameters.h
|
||||||
include/cpr/payload.h
|
include/cpr/payload.h
|
||||||
include/cpr/proxies.h
|
include/cpr/proxies.h
|
||||||
|
include/cpr/proxyauth.h
|
||||||
include/cpr/response.h
|
include/cpr/response.h
|
||||||
include/cpr/session.h
|
include/cpr/session.h
|
||||||
include/cpr/ssl_options.h
|
include/cpr/ssl_options.h
|
||||||
|
2
vendor/CPR/cpr/curlholder.cpp
vendored
2
vendor/CPR/cpr/curlholder.cpp
vendored
@ -25,9 +25,9 @@ CurlHolder::CurlHolder() {
|
|||||||
} // namespace cpr
|
} // namespace cpr
|
||||||
|
|
||||||
CurlHolder::~CurlHolder() {
|
CurlHolder::~CurlHolder() {
|
||||||
curl_easy_cleanup(handle);
|
|
||||||
curl_slist_free_all(chunk);
|
curl_slist_free_all(chunk);
|
||||||
curl_formfree(formpost);
|
curl_formfree(formpost);
|
||||||
|
curl_easy_cleanup(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CurlHolder::urlEncode(const std::string& s) const {
|
std::string CurlHolder::urlEncode(const std::string& s) const {
|
||||||
|
2
vendor/CPR/cpr/multipart.cpp
vendored
2
vendor/CPR/cpr/multipart.cpp
vendored
@ -1,5 +1,5 @@
|
|||||||
#include "cpr/multipart.h"
|
#include "cpr/multipart.h"
|
||||||
|
|
||||||
namespace cpr {
|
namespace cpr {
|
||||||
Multipart::Multipart(const std::initializer_list<Part>& parts) : parts{parts} {}
|
Multipart::Multipart(const std::initializer_list<Part>& p_parts) : parts{p_parts} {}
|
||||||
} // namespace cpr
|
} // namespace cpr
|
||||||
|
17
vendor/CPR/cpr/proxyauth.cpp
vendored
Normal file
17
vendor/CPR/cpr/proxyauth.cpp
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "cpr/proxyauth.h"
|
||||||
|
|
||||||
|
namespace cpr {
|
||||||
|
const char* EncodedAuthentication::GetAuthString() const noexcept {
|
||||||
|
return auth_string_.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProxyAuthentication::has(const std::string& protocol) const {
|
||||||
|
return proxyAuth_.count(protocol) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* ProxyAuthentication::operator[](const std::string& protocol) {
|
||||||
|
return proxyAuth_[protocol].GetAuthString();
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cpr
|
125
vendor/CPR/cpr/session.cpp
vendored
125
vendor/CPR/cpr/session.cpp
vendored
@ -44,6 +44,8 @@ class Session::Impl {
|
|||||||
void SetPayload(const Payload& payload);
|
void SetPayload(const Payload& payload);
|
||||||
void SetProxies(Proxies&& proxies);
|
void SetProxies(Proxies&& proxies);
|
||||||
void SetProxies(const Proxies& proxies);
|
void SetProxies(const Proxies& proxies);
|
||||||
|
void SetProxyAuth(ProxyAuthentication&& proxy_auth);
|
||||||
|
void SetProxyAuth(const ProxyAuthentication& proxy_auth);
|
||||||
void SetMultipart(Multipart&& multipart);
|
void SetMultipart(Multipart&& multipart);
|
||||||
void SetMultipart(const Multipart& multipart);
|
void SetMultipart(const Multipart& multipart);
|
||||||
void SetNTLM(const NTLM& auth);
|
void SetNTLM(const NTLM& auth);
|
||||||
@ -76,6 +78,15 @@ class Session::Impl {
|
|||||||
|
|
||||||
std::shared_ptr<CurlHolder> GetCurlHolder();
|
std::shared_ptr<CurlHolder> GetCurlHolder();
|
||||||
|
|
||||||
|
void PrepareDelete();
|
||||||
|
void PrepareGet();
|
||||||
|
void PrepareHead();
|
||||||
|
void PrepareOptions();
|
||||||
|
void PreparePatch();
|
||||||
|
void PreparePost();
|
||||||
|
void PreparePut();
|
||||||
|
Response Complete(CURLcode curl_error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetHeaderInternal();
|
void SetHeaderInternal();
|
||||||
bool hasBodyOrPayload_{false};
|
bool hasBodyOrPayload_{false};
|
||||||
@ -84,6 +95,7 @@ class Session::Impl {
|
|||||||
Url url_;
|
Url url_;
|
||||||
Parameters parameters_;
|
Parameters parameters_;
|
||||||
Proxies proxies_;
|
Proxies proxies_;
|
||||||
|
ProxyAuthentication proxyAuth_;
|
||||||
Header header_;
|
Header header_;
|
||||||
/**
|
/**
|
||||||
* Will be set by the read callback.
|
* Will be set by the read callback.
|
||||||
@ -96,10 +108,12 @@ class Session::Impl {
|
|||||||
WriteCallback writecb_;
|
WriteCallback writecb_;
|
||||||
ProgressCallback progresscb_;
|
ProgressCallback progresscb_;
|
||||||
DebugCallback debugcb_;
|
DebugCallback debugcb_;
|
||||||
|
std::string response_string_;
|
||||||
|
std::string header_string_;
|
||||||
|
|
||||||
Response makeDownloadRequest();
|
Response makeDownloadRequest();
|
||||||
Response makeRequest();
|
Response makeRequest();
|
||||||
static void freeHolder(CurlHolder* holder);
|
void prepareCommon();
|
||||||
};
|
};
|
||||||
|
|
||||||
Session::Impl::Impl() : curl_(new CurlHolder()) {
|
Session::Impl::Impl() : curl_(new CurlHolder()) {
|
||||||
@ -239,6 +253,14 @@ void Session::Impl::SetProxies(Proxies&& proxies) {
|
|||||||
proxies_ = std::move(proxies);
|
proxies_ = std::move(proxies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::Impl::SetProxyAuth(ProxyAuthentication&& proxy_auth) {
|
||||||
|
proxyAuth_ = std::move(proxy_auth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Session::Impl::SetProxyAuth(const ProxyAuthentication& proxy_auth) {
|
||||||
|
proxyAuth_ = proxy_auth;
|
||||||
|
}
|
||||||
|
|
||||||
void Session::Impl::SetMultipart(Multipart&& multipart) {
|
void Session::Impl::SetMultipart(Multipart&& multipart) {
|
||||||
curl_httppost* formpost = nullptr;
|
curl_httppost* formpost = nullptr;
|
||||||
curl_httppost* lastptr = nullptr;
|
curl_httppost* lastptr = nullptr;
|
||||||
@ -413,6 +435,9 @@ void Session::Impl::SetSslOptions(const SslOptions& options) {
|
|||||||
curl_easy_setopt(curl_->handle, CURLOPT_KEYPASSWD, options.key_pass.c_str());
|
curl_easy_setopt(curl_->handle, CURLOPT_KEYPASSWD, options.key_pass.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!options.pinned_public_key.empty()) {
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_PINNEDPUBLICKEY, options.pinned_public_key.c_str());
|
||||||
|
}
|
||||||
#if SUPPORT_ALPN
|
#if SUPPORT_ALPN
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_ENABLE_ALPN, options.enable_alpn ? ON : OFF);
|
curl_easy_setopt(curl_->handle, CURLOPT_SSL_ENABLE_ALPN, options.enable_alpn ? ON : OFF);
|
||||||
#endif
|
#endif
|
||||||
@ -459,11 +484,15 @@ void Session::Impl::SetSslOptions(const SslOptions& options) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Response Session::Impl::Delete() {
|
void Session::Impl::PrepareDelete() {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPGET, 0L);
|
curl_easy_setopt(curl_->handle, CURLOPT_HTTPGET, 0L);
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "DELETE");
|
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||||
|
prepareCommon();
|
||||||
|
}
|
||||||
|
|
||||||
|
Response Session::Impl::Delete() {
|
||||||
|
PrepareDelete();
|
||||||
return makeRequest();
|
return makeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +514,7 @@ Response Session::Impl::Download(std::ofstream& file) {
|
|||||||
return makeDownloadRequest();
|
return makeDownloadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
Response Session::Impl::Get() {
|
void Session::Impl::PrepareGet() {
|
||||||
// In case there is a body or payload for this request, we create a custom GET-Request since a
|
// In case there is a body or payload for this request, we create a custom GET-Request since a
|
||||||
// GET-Request with body is based on the HTTP RFC **not** a leagal request.
|
// GET-Request with body is based on the HTTP RFC **not** a leagal request.
|
||||||
if (hasBodyOrPayload_) {
|
if (hasBodyOrPayload_) {
|
||||||
@ -496,32 +525,48 @@ Response Session::Impl::Get() {
|
|||||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr);
|
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr);
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPGET, 1L);
|
curl_easy_setopt(curl_->handle, CURLOPT_HTTPGET, 1L);
|
||||||
}
|
}
|
||||||
|
prepareCommon();
|
||||||
|
}
|
||||||
|
|
||||||
|
Response Session::Impl::Get() {
|
||||||
|
PrepareGet();
|
||||||
return makeRequest();
|
return makeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::Impl::PrepareHead() {
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 1L);
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr);
|
||||||
|
prepareCommon();
|
||||||
|
}
|
||||||
|
|
||||||
Response Session::Impl::Head() {
|
Response Session::Impl::Head() {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 1L);
|
PrepareHead();
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr);
|
|
||||||
|
|
||||||
return makeRequest();
|
return makeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::Impl::PrepareOptions() {
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
||||||
|
prepareCommon();
|
||||||
|
}
|
||||||
|
|
||||||
Response Session::Impl::Options() {
|
Response Session::Impl::Options() {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
PrepareOptions();
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
|
||||||
|
|
||||||
return makeRequest();
|
return makeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::Impl::PreparePatch() {
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||||
|
prepareCommon();
|
||||||
|
}
|
||||||
|
|
||||||
Response Session::Impl::Patch() {
|
Response Session::Impl::Patch() {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
PreparePatch();
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "PATCH");
|
|
||||||
|
|
||||||
return makeRequest();
|
return makeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
Response Session::Impl::Post() {
|
void Session::Impl::PreparePost() {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||||
|
|
||||||
// In case there is no body or payload set it to an empty post:
|
// In case there is no body or payload set it to an empty post:
|
||||||
@ -531,14 +576,22 @@ Response Session::Impl::Post() {
|
|||||||
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDS, readcb_.callback ? nullptr : "");
|
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDS, readcb_.callback ? nullptr : "");
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "POST");
|
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
}
|
}
|
||||||
|
prepareCommon();
|
||||||
|
}
|
||||||
|
|
||||||
|
Response Session::Impl::Post() {
|
||||||
|
PreparePost();
|
||||||
return makeRequest();
|
return makeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
Response Session::Impl::Put() {
|
void Session::Impl::PreparePut() {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "PUT");
|
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||||
|
prepareCommon();
|
||||||
|
}
|
||||||
|
|
||||||
|
Response Session::Impl::Put() {
|
||||||
|
PreparePut();
|
||||||
return makeRequest();
|
return makeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,6 +612,10 @@ Response Session::Impl::makeDownloadRequest() {
|
|||||||
std::string protocol = url_.str().substr(0, url_.str().find(':'));
|
std::string protocol = url_.str().substr(0, url_.str().find(':'));
|
||||||
if (proxies_.has(protocol)) {
|
if (proxies_.has(protocol)) {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, proxies_[protocol].c_str());
|
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, proxies_[protocol].c_str());
|
||||||
|
if (proxyAuth_.has(protocol)) {
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_PROXYUSERPWD, proxyAuth_[protocol]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, "");
|
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, "");
|
||||||
}
|
}
|
||||||
@ -586,7 +643,7 @@ Response Session::Impl::makeDownloadRequest() {
|
|||||||
Error(curl_error, std::move(errorMsg)));
|
Error(curl_error, std::move(errorMsg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response Session::Impl::makeRequest() {
|
void Session::Impl::prepareCommon() {
|
||||||
assert(curl_->handle);
|
assert(curl_->handle);
|
||||||
|
|
||||||
// Set Header:
|
// Set Header:
|
||||||
@ -604,6 +661,10 @@ Response Session::Impl::makeRequest() {
|
|||||||
std::string protocol = url_.str().substr(0, url_.str().find(':'));
|
std::string protocol = url_.str().substr(0, url_.str().find(':'));
|
||||||
if (proxies_.has(protocol)) {
|
if (proxies_.has(protocol)) {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, proxies_[protocol].c_str());
|
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, proxies_[protocol].c_str());
|
||||||
|
if (proxyAuth_.has(protocol)) {
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
|
||||||
|
curl_easy_setopt(curl_->handle, CURLOPT_PROXYUSERPWD, proxyAuth_[protocol]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, nullptr);
|
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, nullptr);
|
||||||
}
|
}
|
||||||
@ -624,22 +685,29 @@ Response Session::Impl::makeRequest() {
|
|||||||
|
|
||||||
curl_->error[0] = '\0';
|
curl_->error[0] = '\0';
|
||||||
|
|
||||||
std::string response_string;
|
response_string_.clear();
|
||||||
std::string header_string;
|
header_string_.clear();
|
||||||
if (!this->writecb_.callback) {
|
if (!this->writecb_.callback) {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_WRITEFUNCTION, cpr::util::writeFunction);
|
curl_easy_setopt(curl_->handle, CURLOPT_WRITEFUNCTION, cpr::util::writeFunction);
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_WRITEDATA, &response_string);
|
curl_easy_setopt(curl_->handle, CURLOPT_WRITEDATA, &response_string_);
|
||||||
}
|
}
|
||||||
if (!this->headercb_.callback) {
|
if (!this->headercb_.callback) {
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::writeFunction);
|
curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::writeFunction);
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &header_string);
|
curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &header_string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable so we are able to retrive certificate information:
|
// Enable so we are able to retrive certificate information:
|
||||||
curl_easy_setopt(curl_->handle, CURLOPT_CERTINFO, 1L);
|
curl_easy_setopt(curl_->handle, CURLOPT_CERTINFO, 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
Response Session::Impl::makeRequest()
|
||||||
|
{
|
||||||
CURLcode curl_error = curl_easy_perform(curl_->handle);
|
CURLcode curl_error = curl_easy_perform(curl_->handle);
|
||||||
|
return Complete(curl_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
Response Session::Impl::Complete(CURLcode curl_error)
|
||||||
|
{
|
||||||
curl_slist* raw_cookies{nullptr};
|
curl_slist* raw_cookies{nullptr};
|
||||||
curl_easy_getinfo(curl_->handle, CURLINFO_COOKIELIST, &raw_cookies);
|
curl_easy_getinfo(curl_->handle, CURLINFO_COOKIELIST, &raw_cookies);
|
||||||
Cookies cookies = util::parseCookies(raw_cookies);
|
Cookies cookies = util::parseCookies(raw_cookies);
|
||||||
@ -649,17 +717,20 @@ Response Session::Impl::makeRequest() {
|
|||||||
hasBodyOrPayload_ = false;
|
hasBodyOrPayload_ = false;
|
||||||
|
|
||||||
std::string errorMsg = curl_->error.data();
|
std::string errorMsg = curl_->error.data();
|
||||||
return Response(curl_, std::move(response_string), std::move(header_string), std::move(cookies),
|
return Response(curl_, std::move(response_string_), std::move(header_string_), std::move(cookies),
|
||||||
Error(curl_error, std::move(errorMsg)));
|
Error(curl_error, std::move(errorMsg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
Session::Session() : pimpl_(new Impl()) {}
|
Session::Session() : pimpl_(new Impl()) {}
|
||||||
|
Session::Session(Session&& old) noexcept = default;
|
||||||
Session::~Session() = default;
|
Session::~Session() = default;
|
||||||
|
Session& Session::operator=(Session&& old) noexcept = default;
|
||||||
void Session::SetReadCallback(const ReadCallback& read) { pimpl_->SetReadCallback(read); }
|
void Session::SetReadCallback(const ReadCallback& read) { pimpl_->SetReadCallback(read); }
|
||||||
void Session::SetHeaderCallback(const HeaderCallback& header) { pimpl_->SetHeaderCallback(header); }
|
void Session::SetHeaderCallback(const HeaderCallback& header) { pimpl_->SetHeaderCallback(header); }
|
||||||
void Session::SetWriteCallback(const WriteCallback& write) { pimpl_->SetWriteCallback(write); }
|
void Session::SetWriteCallback(const WriteCallback& write) { pimpl_->SetWriteCallback(write); }
|
||||||
void Session::SetProgressCallback(const ProgressCallback& progress) { pimpl_->SetProgressCallback(progress); }
|
void Session::SetProgressCallback(const ProgressCallback& progress) { pimpl_->SetProgressCallback(progress); }
|
||||||
|
void Session::SetDebugCallback(const DebugCallback& debug) { pimpl_->SetDebugCallback(debug); }
|
||||||
void Session::SetUrl(const Url& url) { pimpl_->SetUrl(url); }
|
void Session::SetUrl(const Url& url) { pimpl_->SetUrl(url); }
|
||||||
void Session::SetParameters(const Parameters& parameters) { pimpl_->SetParameters(parameters); }
|
void Session::SetParameters(const Parameters& parameters) { pimpl_->SetParameters(parameters); }
|
||||||
void Session::SetParameters(Parameters&& parameters) { pimpl_->SetParameters(std::move(parameters)); }
|
void Session::SetParameters(Parameters&& parameters) { pimpl_->SetParameters(std::move(parameters)); }
|
||||||
@ -674,6 +745,8 @@ void Session::SetPayload(const Payload& payload) { pimpl_->SetPayload(payload);
|
|||||||
void Session::SetPayload(Payload&& payload) { pimpl_->SetPayload(std::move(payload)); }
|
void Session::SetPayload(Payload&& payload) { pimpl_->SetPayload(std::move(payload)); }
|
||||||
void Session::SetProxies(const Proxies& proxies) { pimpl_->SetProxies(proxies); }
|
void Session::SetProxies(const Proxies& proxies) { pimpl_->SetProxies(proxies); }
|
||||||
void Session::SetProxies(Proxies&& proxies) { pimpl_->SetProxies(std::move(proxies)); }
|
void Session::SetProxies(Proxies&& proxies) { pimpl_->SetProxies(std::move(proxies)); }
|
||||||
|
void Session::SetProxyAuth(ProxyAuthentication&& proxy_auth) { pimpl_->SetProxyAuth(std::move(proxy_auth)); }
|
||||||
|
void Session::SetProxyAuth(const ProxyAuthentication& proxy_auth) { pimpl_->SetProxyAuth(proxy_auth); }
|
||||||
void Session::SetMultipart(const Multipart& multipart) { pimpl_->SetMultipart(multipart); }
|
void Session::SetMultipart(const Multipart& multipart) { pimpl_->SetMultipart(multipart); }
|
||||||
void Session::SetMultipart(Multipart&& multipart) { pimpl_->SetMultipart(std::move(multipart)); }
|
void Session::SetMultipart(Multipart&& multipart) { pimpl_->SetMultipart(std::move(multipart)); }
|
||||||
void Session::SetNTLM(const NTLM& auth) { pimpl_->SetNTLM(auth); }
|
void Session::SetNTLM(const NTLM& auth) { pimpl_->SetNTLM(auth); }
|
||||||
@ -711,6 +784,8 @@ void Session::SetOption(const Payload& payload) { pimpl_->SetPayload(payload); }
|
|||||||
void Session::SetOption(Payload&& payload) { pimpl_->SetPayload(std::move(payload)); }
|
void Session::SetOption(Payload&& payload) { pimpl_->SetPayload(std::move(payload)); }
|
||||||
void Session::SetOption(const Proxies& proxies) { pimpl_->SetProxies(proxies); }
|
void Session::SetOption(const Proxies& proxies) { pimpl_->SetProxies(proxies); }
|
||||||
void Session::SetOption(Proxies&& proxies) { pimpl_->SetProxies(std::move(proxies)); }
|
void Session::SetOption(Proxies&& proxies) { pimpl_->SetProxies(std::move(proxies)); }
|
||||||
|
void Session::SetOption(ProxyAuthentication&& proxy_auth) { pimpl_->SetProxyAuth(std::move(proxy_auth)); }
|
||||||
|
void Session::SetOption(const ProxyAuthentication& proxy_auth) { pimpl_->SetProxyAuth(proxy_auth); }
|
||||||
void Session::SetOption(const Multipart& multipart) { pimpl_->SetMultipart(multipart); }
|
void Session::SetOption(const Multipart& multipart) { pimpl_->SetMultipart(multipart); }
|
||||||
void Session::SetOption(Multipart&& multipart) { pimpl_->SetMultipart(std::move(multipart)); }
|
void Session::SetOption(Multipart&& multipart) { pimpl_->SetMultipart(std::move(multipart)); }
|
||||||
void Session::SetOption(const NTLM& auth) { pimpl_->SetNTLM(auth); }
|
void Session::SetOption(const NTLM& auth) { pimpl_->SetNTLM(auth); }
|
||||||
@ -736,5 +811,15 @@ Response Session::Post() { return pimpl_->Post(); }
|
|||||||
Response Session::Put() { return pimpl_->Put(); }
|
Response Session::Put() { return pimpl_->Put(); }
|
||||||
|
|
||||||
std::shared_ptr<CurlHolder> Session::GetCurlHolder() { return pimpl_->GetCurlHolder(); }
|
std::shared_ptr<CurlHolder> Session::GetCurlHolder() { return pimpl_->GetCurlHolder(); }
|
||||||
|
|
||||||
|
void Session::PrepareDelete() { return pimpl_->PrepareDelete(); }
|
||||||
|
void Session::PrepareGet() { return pimpl_->PrepareGet(); }
|
||||||
|
void Session::PrepareHead() { return pimpl_->PrepareHead(); }
|
||||||
|
void Session::PrepareOptions() { return pimpl_->PrepareOptions(); }
|
||||||
|
void Session::PreparePatch() { return pimpl_->PreparePatch(); }
|
||||||
|
void Session::PreparePost() { return pimpl_->PreparePost(); }
|
||||||
|
void Session::PreparePut() { return pimpl_->PreparePut(); }
|
||||||
|
Response Session::Complete( CURLcode curl_error ) { return pimpl_->Complete(curl_error); }
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
} // namespace cpr
|
} // namespace cpr
|
||||||
|
41
vendor/CPR/include/cpr/api.h
vendored
41
vendor/CPR/include/cpr/api.h
vendored
@ -24,15 +24,10 @@ using AsyncResponse = std::future<Response>;
|
|||||||
|
|
||||||
namespace priv {
|
namespace priv {
|
||||||
|
|
||||||
template <typename T>
|
template <typename... Ts>
|
||||||
void set_option(Session& session, T&& t) {
|
void set_option(Session& session, Ts&&... ts) {
|
||||||
session.SetOption(std::forward<T>(t));
|
std::initializer_list<int> ignore = { (session.SetOption(std::forward<Ts>(ts)), 0)... };
|
||||||
}
|
(void)ignore;
|
||||||
|
|
||||||
template <typename T, typename... Ts>
|
|
||||||
void set_option(Session& session, T&& t, Ts&&... ts) {
|
|
||||||
set_option(session, std::forward<T>(t));
|
|
||||||
set_option(session, std::forward<Ts>(ts)...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
@ -49,7 +44,7 @@ Response Get(Ts&&... ts) {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
AsyncResponse GetAsync(Ts... ts) {
|
AsyncResponse GetAsync(Ts... ts) {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Ts... ts) { return Get(std::move(ts)...); }, std::move(ts)...);
|
std::launch::async, [](Ts... ts_inner) { return Get(std::move(ts_inner)...); }, std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get callback methods
|
// Get callback methods
|
||||||
@ -57,7 +52,7 @@ template <typename Then, typename... Ts>
|
|||||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||||
auto GetCallback(Then then, Ts... ts) -> std::future<decltype(then(Get(std::move(ts)...)))> {
|
auto GetCallback(Then then, Ts... ts) -> std::future<decltype(then(Get(std::move(ts)...)))> {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Then then, Ts... ts) { return then(Get(std::move(ts)...)); },
|
std::launch::async, [](Then then_inner, Ts... ts_inner) { return then_inner(Get(std::move(ts_inner)...)); },
|
||||||
std::move(then), std::move(ts)...);
|
std::move(then), std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +68,7 @@ Response Post(Ts&&... ts) {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
AsyncResponse PostAsync(Ts... ts) {
|
AsyncResponse PostAsync(Ts... ts) {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Ts... ts) { return Post(std::move(ts)...); }, std::move(ts)...);
|
std::launch::async, [](Ts... ts_inner) { return Post(std::move(ts_inner)...); }, std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post callback methods
|
// Post callback methods
|
||||||
@ -81,7 +76,7 @@ template <typename Then, typename... Ts>
|
|||||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||||
auto PostCallback(Then then, Ts... ts) -> std::future<decltype(then(Post(std::move(ts)...)))> {
|
auto PostCallback(Then then, Ts... ts) -> std::future<decltype(then(Post(std::move(ts)...)))> {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Then then, Ts... ts) { return then(Post(std::move(ts)...)); },
|
std::launch::async, [](Then then_inner, Ts... ts_inner) { return then_inner(Post(std::move(ts_inner)...)); },
|
||||||
std::move(then), std::move(ts)...);
|
std::move(then), std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +92,7 @@ Response Put(Ts&&... ts) {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
AsyncResponse PutAsync(Ts... ts) {
|
AsyncResponse PutAsync(Ts... ts) {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Ts... ts) { return Put(std::move(ts)...); }, std::move(ts)...);
|
std::launch::async, [](Ts... ts_inner) { return Put(std::move(ts_inner)...); }, std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put callback methods
|
// Put callback methods
|
||||||
@ -105,7 +100,7 @@ template <typename Then, typename... Ts>
|
|||||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||||
auto PutCallback(Then then, Ts... ts) -> std::future<decltype(then(Put(std::move(ts)...)))> {
|
auto PutCallback(Then then, Ts... ts) -> std::future<decltype(then(Put(std::move(ts)...)))> {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Then then, Ts... ts) { return then(Put(std::move(ts)...)); },
|
std::launch::async, [](Then then_inner, Ts... ts_inner) { return then_inner(Put(std::move(ts_inner)...)); },
|
||||||
std::move(then), std::move(ts)...);
|
std::move(then), std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +116,7 @@ Response Head(Ts&&... ts) {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
AsyncResponse HeadAsync(Ts... ts) {
|
AsyncResponse HeadAsync(Ts... ts) {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Ts... ts) { return Head(std::move(ts)...); }, std::move(ts)...);
|
std::launch::async, [](Ts... ts_inner) { return Head(std::move(ts_inner)...); }, std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Head callback methods
|
// Head callback methods
|
||||||
@ -129,7 +124,7 @@ template <typename Then, typename... Ts>
|
|||||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||||
auto HeadCallback(Then then, Ts... ts) -> std::future<decltype(then(Head(std::move(ts)...)))> {
|
auto HeadCallback(Then then, Ts... ts) -> std::future<decltype(then(Head(std::move(ts)...)))> {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Then then, Ts... ts) { return then(Head(std::move(ts)...)); },
|
std::launch::async, [](Then then_inner, Ts... ts_inner) { return then_inner(Head(std::move(ts_inner)...)); },
|
||||||
std::move(then), std::move(ts)...);
|
std::move(then), std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +140,7 @@ Response Delete(Ts&&... ts) {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
AsyncResponse DeleteAsync(Ts... ts) {
|
AsyncResponse DeleteAsync(Ts... ts) {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Ts... ts) { return Delete(std::move(ts)...); },
|
std::launch::async, [](Ts... ts_inner) { return Delete(std::move(ts_inner)...); },
|
||||||
std::move(ts)...);
|
std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +149,7 @@ template <typename Then, typename... Ts>
|
|||||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||||
auto DeleteCallback(Then then, Ts... ts) -> std::future<decltype(then(Delete(std::move(ts)...)))> {
|
auto DeleteCallback(Then then, Ts... ts) -> std::future<decltype(then(Delete(std::move(ts)...)))> {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Then then, Ts... ts) { return then(Delete(std::move(ts)...)); },
|
std::launch::async, [](Then then_inner, Ts... ts_inner) { return then_inner(Delete(std::move(ts_inner)...)); },
|
||||||
std::move(then), std::move(ts)...);
|
std::move(then), std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +165,7 @@ Response Options(Ts&&... ts) {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
AsyncResponse OptionsAsync(Ts... ts) {
|
AsyncResponse OptionsAsync(Ts... ts) {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Ts... ts) { return Options(std::move(ts)...); },
|
std::launch::async, [](Ts... ts_inner) { return Options(std::move(ts_inner)...); },
|
||||||
std::move(ts)...);
|
std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +175,7 @@ template <typename Then, typename... Ts>
|
|||||||
auto OptionsCallback(Then then, Ts... ts)
|
auto OptionsCallback(Then then, Ts... ts)
|
||||||
-> std::future<decltype(then(Options(std::move(ts)...)))> {
|
-> std::future<decltype(then(Options(std::move(ts)...)))> {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Then then, Ts... ts) { return then(Options(std::move(ts)...)); },
|
std::launch::async, [](Then then_inner, Ts... ts_inner) { return then_inner(Options(std::move(ts_inner)...)); },
|
||||||
std::move(then), std::move(ts)...);
|
std::move(then), std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +191,7 @@ Response Patch(Ts&&... ts) {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
AsyncResponse PatchAsync(Ts... ts) {
|
AsyncResponse PatchAsync(Ts... ts) {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Ts... ts) { return Patch(std::move(ts)...); }, std::move(ts)...);
|
std::launch::async, [](Ts... ts_inner) { return Patch(std::move(ts_inner)...); }, std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch callback methods
|
// Patch callback methods
|
||||||
@ -204,7 +199,7 @@ template <typename Then, typename... Ts>
|
|||||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||||
auto PatchCallback(Then then, Ts... ts) -> std::future<decltype(then(Patch(std::move(ts)...)))> {
|
auto PatchCallback(Then then, Ts... ts) -> std::future<decltype(then(Patch(std::move(ts)...)))> {
|
||||||
return std::async(
|
return std::async(
|
||||||
std::launch::async, [](Then then, Ts... ts) { return then(Patch(std::move(ts)...)); },
|
std::launch::async, [](Then then_inner, Ts... ts_inner) { return then_inner(Patch(std::move(ts_inner)...)); },
|
||||||
std::move(then), std::move(ts)...);
|
std::move(then), std::move(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
vendor/CPR/include/cpr/callback.h
vendored
22
vendor/CPR/include/cpr/callback.h
vendored
@ -12,10 +12,10 @@ class ReadCallback {
|
|||||||
public:
|
public:
|
||||||
ReadCallback() = default;
|
ReadCallback() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
ReadCallback(std::function<bool(char* buffer, size_t& size)> callback)
|
ReadCallback(std::function<bool(char* buffer, size_t& size)> p_callback)
|
||||||
: size{-1}, callback{std::move(callback)} {}
|
: size{-1}, callback{std::move(p_callback)} {}
|
||||||
ReadCallback(cpr_off_t size, std::function<bool(char* buffer, size_t& size)> callback)
|
ReadCallback(cpr_off_t p_size, std::function<bool(char* buffer, size_t& size)> p_callback)
|
||||||
: size{size}, callback{std::move(callback)} {}
|
: size{p_size}, callback{std::move(p_callback)} {}
|
||||||
|
|
||||||
cpr_off_t size{};
|
cpr_off_t size{};
|
||||||
std::function<bool(char* buffer, size_t& size)> callback;
|
std::function<bool(char* buffer, size_t& size)> callback;
|
||||||
@ -25,8 +25,8 @@ class HeaderCallback {
|
|||||||
public:
|
public:
|
||||||
HeaderCallback() = default;
|
HeaderCallback() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
HeaderCallback(std::function<bool(std::string header)> callback)
|
HeaderCallback(std::function<bool(std::string header)> p_callback)
|
||||||
: callback(std::move(callback)) {}
|
: callback(std::move(p_callback)) {}
|
||||||
|
|
||||||
std::function<bool(std::string header)> callback;
|
std::function<bool(std::string header)> callback;
|
||||||
};
|
};
|
||||||
@ -35,7 +35,7 @@ class WriteCallback {
|
|||||||
public:
|
public:
|
||||||
WriteCallback() = default;
|
WriteCallback() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
WriteCallback(std::function<bool(std::string data)> callback) : callback(std::move(callback)) {}
|
WriteCallback(std::function<bool(std::string data)> p_callback) : callback(std::move(p_callback)) {}
|
||||||
|
|
||||||
std::function<bool(std::string data)> callback;
|
std::function<bool(std::string data)> callback;
|
||||||
};
|
};
|
||||||
@ -46,8 +46,8 @@ class ProgressCallback {
|
|||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
ProgressCallback(std::function<bool(size_t downloadTotal, size_t downloadNow,
|
ProgressCallback(std::function<bool(size_t downloadTotal, size_t downloadNow,
|
||||||
size_t uploadTotal, size_t uploadNow)>
|
size_t uploadTotal, size_t uploadNow)>
|
||||||
callback)
|
p_callback)
|
||||||
: callback(std::move(callback)) {}
|
: callback(std::move(p_callback)) {}
|
||||||
|
|
||||||
std::function<bool(size_t downloadTotal, size_t downloadNow, size_t uploadTotal,
|
std::function<bool(size_t downloadTotal, size_t downloadNow, size_t uploadTotal,
|
||||||
size_t uploadNow)>
|
size_t uploadNow)>
|
||||||
@ -67,8 +67,8 @@ class DebugCallback {
|
|||||||
};
|
};
|
||||||
DebugCallback() = default;
|
DebugCallback() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
DebugCallback(std::function<void(InfoType type, std::string data)> callback)
|
DebugCallback(std::function<void(InfoType type, std::string data)> p_callback)
|
||||||
: callback(std::move(callback)) {}
|
: callback(std::move(p_callback)) {}
|
||||||
|
|
||||||
std::function<void(InfoType type, std::string data)> callback;
|
std::function<void(InfoType type, std::string data)> callback;
|
||||||
};
|
};
|
||||||
|
10
vendor/CPR/include/cpr/cookies.h
vendored
10
vendor/CPR/include/cpr/cookies.h
vendored
@ -25,13 +25,13 @@ class Cookies {
|
|||||||
bool encode{true};
|
bool encode{true};
|
||||||
|
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
Cookies(bool encode = true) : encode(encode) {}
|
Cookies(bool p_encode = true) : encode(p_encode) {}
|
||||||
Cookies(const std::initializer_list<std::pair<const std::string, std::string>>& pairs,
|
Cookies(const std::initializer_list<std::pair<const std::string, std::string>>& pairs,
|
||||||
bool encode = true)
|
bool p_encode = true)
|
||||||
: encode(encode), map_{pairs} {}
|
: encode(p_encode), map_{pairs} {}
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
Cookies(const std::map<std::string, std::string>& map, bool encode = true)
|
Cookies(const std::map<std::string, std::string>& map, bool p_encode = true)
|
||||||
: encode(encode), map_{map} {}
|
: encode(p_encode), map_{map} {}
|
||||||
|
|
||||||
std::string& operator[](const std::string& key);
|
std::string& operator[](const std::string& key);
|
||||||
std::string GetEncoded(const CurlHolder& holder) const;
|
std::string GetEncoded(const CurlHolder& holder) const;
|
||||||
|
6
vendor/CPR/include/cpr/curl_container.h
vendored
6
vendor/CPR/include/cpr/curl_container.h
vendored
@ -12,9 +12,9 @@
|
|||||||
namespace cpr {
|
namespace cpr {
|
||||||
|
|
||||||
struct Parameter {
|
struct Parameter {
|
||||||
Parameter(const std::string& key, const std::string& value) : key{key}, value{value} {}
|
Parameter(const std::string& p_key, const std::string& p_value) : key{p_key}, value{p_value} {}
|
||||||
Parameter(std::string&& key, std::string&& value)
|
Parameter(std::string&& p_key, std::string&& p_value)
|
||||||
: key{std::move(key)}, value{std::move(value)} {}
|
: key{std::move(p_key)}, value{std::move(p_value)} {}
|
||||||
|
|
||||||
std::string key;
|
std::string key;
|
||||||
std::string value;
|
std::string value;
|
||||||
|
4
vendor/CPR/include/cpr/limit_rate.h
vendored
4
vendor/CPR/include/cpr/limit_rate.h
vendored
@ -7,8 +7,8 @@ namespace cpr {
|
|||||||
|
|
||||||
class LimitRate {
|
class LimitRate {
|
||||||
public:
|
public:
|
||||||
LimitRate(const std::int64_t downrate, const std::int64_t uprate)
|
LimitRate(const std::int64_t p_downrate, const std::int64_t p_uprate)
|
||||||
: downrate(downrate), uprate(uprate) {}
|
: downrate(p_downrate), uprate(p_uprate) {}
|
||||||
|
|
||||||
std::int64_t downrate = 0;
|
std::int64_t downrate = 0;
|
||||||
std::int64_t uprate = 0;
|
std::int64_t uprate = 0;
|
||||||
|
2
vendor/CPR/include/cpr/low_speed.h
vendored
2
vendor/CPR/include/cpr/low_speed.h
vendored
@ -7,7 +7,7 @@ namespace cpr {
|
|||||||
|
|
||||||
class LowSpeed {
|
class LowSpeed {
|
||||||
public:
|
public:
|
||||||
LowSpeed(const std::int32_t limit, const std::int32_t time) : limit(limit), time(time) {}
|
LowSpeed(const std::int32_t p_limit, const std::int32_t p_time) : limit(p_limit), time(p_time) {}
|
||||||
|
|
||||||
std::int32_t limit;
|
std::int32_t limit;
|
||||||
std::int32_t time;
|
std::int32_t time;
|
||||||
|
4
vendor/CPR/include/cpr/max_redirects.h
vendored
4
vendor/CPR/include/cpr/max_redirects.h
vendored
@ -7,8 +7,8 @@ namespace cpr {
|
|||||||
|
|
||||||
class MaxRedirects {
|
class MaxRedirects {
|
||||||
public:
|
public:
|
||||||
explicit MaxRedirects(const std::int32_t number_of_redirects)
|
explicit MaxRedirects(const std::int32_t p_number_of_redirects)
|
||||||
: number_of_redirects(number_of_redirects) {}
|
: number_of_redirects(p_number_of_redirects) {}
|
||||||
|
|
||||||
std::int32_t number_of_redirects;
|
std::int32_t number_of_redirects;
|
||||||
};
|
};
|
||||||
|
30
vendor/CPR/include/cpr/multipart.h
vendored
30
vendor/CPR/include/cpr/multipart.h
vendored
@ -10,8 +10,8 @@
|
|||||||
namespace cpr {
|
namespace cpr {
|
||||||
|
|
||||||
struct File {
|
struct File {
|
||||||
explicit File(std::string&& filepath) : filepath(std::move(filepath)) {}
|
explicit File(std::string&& p_filepath) : filepath(std::move(p_filepath)) {}
|
||||||
explicit File(const std::string& filepath) : filepath(filepath) {}
|
explicit File(const std::string& p_filepath) : filepath(p_filepath) {}
|
||||||
const std::string filepath;
|
const std::string filepath;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,13 +19,13 @@ struct Buffer {
|
|||||||
using data_t = const unsigned char*;
|
using data_t = const unsigned char*;
|
||||||
|
|
||||||
template <typename Iterator>
|
template <typename Iterator>
|
||||||
Buffer(Iterator begin, Iterator end, std::string&& filename)
|
Buffer(Iterator begin, Iterator end, std::string&& p_filename)
|
||||||
// Ignored here since libcurl reqires a long.
|
// Ignored here since libcurl reqires a long.
|
||||||
// There is also no way around the reinterpret_cast.
|
// There is also no way around the reinterpret_cast.
|
||||||
// NOLINTNEXTLINE(google-runtime-int, cppcoreguidelines-pro-type-reinterpret-cast)
|
// NOLINTNEXTLINE(google-runtime-int, cppcoreguidelines-pro-type-reinterpret-cast)
|
||||||
: data{reinterpret_cast<data_t>(&(*begin))}, datalen{static_cast<long>(
|
: data{reinterpret_cast<data_t>(&(*begin))}, datalen{static_cast<long>(
|
||||||
std::distance(begin, end))},
|
std::distance(begin, end))},
|
||||||
filename(std::move(filename)) {
|
filename(std::move(p_filename)) {
|
||||||
is_random_access_iterator(begin, end);
|
is_random_access_iterator(begin, end);
|
||||||
static_assert(sizeof(*begin) == 1, "only byte buffers can be used");
|
static_assert(sizeof(*begin) == 1, "only byte buffers can be used");
|
||||||
}
|
}
|
||||||
@ -43,17 +43,17 @@ struct Buffer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Part {
|
struct Part {
|
||||||
Part(const std::string& name, const std::string& value, const std::string& content_type = {})
|
Part(const std::string& p_name, const std::string& p_value, const std::string& p_content_type = {})
|
||||||
: name{name}, value{value},
|
: name{p_name}, value{p_value},
|
||||||
content_type{content_type}, is_file{false}, is_buffer{false} {}
|
content_type{p_content_type}, is_file{false}, is_buffer{false} {}
|
||||||
Part(const std::string& name, const std::int32_t& value, const std::string& content_type = {})
|
Part(const std::string& p_name, const std::int32_t& p_value, const std::string& p_content_type = {})
|
||||||
: name{name}, value{std::to_string(value)},
|
: name{p_name}, value{std::to_string(p_value)},
|
||||||
content_type{content_type}, is_file{false}, is_buffer{false} {}
|
content_type{p_content_type}, is_file{false}, is_buffer{false} {}
|
||||||
Part(const std::string& name, const File& file, const std::string& content_type = {})
|
Part(const std::string& p_name, const File& file, const std::string& p_content_type = {})
|
||||||
: name{name}, value{file.filepath},
|
: name{p_name}, value{file.filepath},
|
||||||
content_type{content_type}, is_file{true}, is_buffer{false} {}
|
content_type{p_content_type}, is_file{true}, is_buffer{false} {}
|
||||||
Part(const std::string& name, const Buffer& buffer, const std::string& content_type = {})
|
Part(const std::string& p_name, const Buffer& buffer, const std::string& p_content_type = {})
|
||||||
: name{name}, value{buffer.filename}, content_type{content_type}, data{buffer.data},
|
: name{p_name}, value{buffer.filename}, content_type{p_content_type}, data{buffer.data},
|
||||||
datalen{buffer.datalen}, is_file{false}, is_buffer{true} {}
|
datalen{buffer.datalen}, is_file{false}, is_buffer{true} {}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
43
vendor/CPR/include/cpr/proxyauth.h
vendored
Normal file
43
vendor/CPR/include/cpr/proxyauth.h
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#ifndef CPR_PROXYAUTH_H
|
||||||
|
#define CPR_PROXYAUTH_H
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "cpr/auth.h"
|
||||||
|
#include "cpr/util.h"
|
||||||
|
|
||||||
|
namespace cpr {
|
||||||
|
class EncodedAuthentication {
|
||||||
|
public:
|
||||||
|
EncodedAuthentication() : auth_string_{""} {}
|
||||||
|
EncodedAuthentication(const std::string& username, const std::string& password) : auth_string_{cpr::util::urlEncode(username) + ":" + cpr::util::urlEncode(password)} {}
|
||||||
|
EncodedAuthentication(std::string&& username, std::string&& password) : auth_string_{cpr::util::urlEncode(std::move(username)) + ":" + cpr::util::urlEncode(std::move(password))} {}
|
||||||
|
EncodedAuthentication(const EncodedAuthentication& other) = default;
|
||||||
|
EncodedAuthentication(EncodedAuthentication&& old) noexcept = default;
|
||||||
|
virtual ~EncodedAuthentication() noexcept = default;
|
||||||
|
|
||||||
|
EncodedAuthentication& operator=(EncodedAuthentication&& old) noexcept = default;
|
||||||
|
EncodedAuthentication& operator=(const EncodedAuthentication& other) = default;
|
||||||
|
|
||||||
|
const char* GetAuthString() const noexcept;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string auth_string_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProxyAuthentication {
|
||||||
|
public:
|
||||||
|
ProxyAuthentication() = default;
|
||||||
|
ProxyAuthentication(const std::initializer_list<std::pair<const std::string, EncodedAuthentication>>& auths) : proxyAuth_{auths} {}
|
||||||
|
|
||||||
|
bool has(const std::string& protocol) const;
|
||||||
|
const char* operator[](const std::string& protocol);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<std::string, EncodedAuthentication> proxyAuth_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cpr
|
||||||
|
|
||||||
|
#endif
|
20
vendor/CPR/include/cpr/session.h
vendored
20
vendor/CPR/include/cpr/session.h
vendored
@ -22,6 +22,7 @@
|
|||||||
#include "cpr/parameters.h"
|
#include "cpr/parameters.h"
|
||||||
#include "cpr/payload.h"
|
#include "cpr/payload.h"
|
||||||
#include "cpr/proxies.h"
|
#include "cpr/proxies.h"
|
||||||
|
#include "cpr/proxyauth.h"
|
||||||
#include "cpr/response.h"
|
#include "cpr/response.h"
|
||||||
#include "cpr/ssl_options.h"
|
#include "cpr/ssl_options.h"
|
||||||
#include "cpr/timeout.h"
|
#include "cpr/timeout.h"
|
||||||
@ -34,12 +35,12 @@ namespace cpr {
|
|||||||
class Session {
|
class Session {
|
||||||
public:
|
public:
|
||||||
Session();
|
Session();
|
||||||
Session(Session&& old) noexcept = default;
|
Session(Session&& old) noexcept;
|
||||||
Session(const Session& other) = delete;
|
Session(const Session& other) = delete;
|
||||||
|
|
||||||
~Session();
|
~Session();
|
||||||
|
|
||||||
Session& operator=(Session&& old) noexcept = default;
|
Session& operator=(Session&& old) noexcept;
|
||||||
Session& operator=(const Session& other) = delete;
|
Session& operator=(const Session& other) = delete;
|
||||||
|
|
||||||
void SetUrl(const Url& url);
|
void SetUrl(const Url& url);
|
||||||
@ -56,6 +57,8 @@ class Session {
|
|||||||
void SetPayload(const Payload& payload);
|
void SetPayload(const Payload& payload);
|
||||||
void SetProxies(Proxies&& proxies);
|
void SetProxies(Proxies&& proxies);
|
||||||
void SetProxies(const Proxies& proxies);
|
void SetProxies(const Proxies& proxies);
|
||||||
|
void SetProxyAuth(ProxyAuthentication&& proxy_auth);
|
||||||
|
void SetProxyAuth(const ProxyAuthentication& proxy_auth);
|
||||||
void SetMultipart(Multipart&& multipart);
|
void SetMultipart(Multipart&& multipart);
|
||||||
void SetMultipart(const Multipart& multipart);
|
void SetMultipart(const Multipart& multipart);
|
||||||
void SetNTLM(const NTLM& auth);
|
void SetNTLM(const NTLM& auth);
|
||||||
@ -95,6 +98,8 @@ class Session {
|
|||||||
void SetOption(const LimitRate& limit_rate);
|
void SetOption(const LimitRate& limit_rate);
|
||||||
void SetOption(Proxies&& proxies);
|
void SetOption(Proxies&& proxies);
|
||||||
void SetOption(const Proxies& proxies);
|
void SetOption(const Proxies& proxies);
|
||||||
|
void SetOption(ProxyAuthentication&& proxy_auth);
|
||||||
|
void SetOption(const ProxyAuthentication& proxy_auth);
|
||||||
void SetOption(Multipart&& multipart);
|
void SetOption(Multipart&& multipart);
|
||||||
void SetOption(const Multipart& multipart);
|
void SetOption(const Multipart& multipart);
|
||||||
void SetOption(const NTLM& auth);
|
void SetOption(const NTLM& auth);
|
||||||
@ -126,7 +131,16 @@ class Session {
|
|||||||
|
|
||||||
std::shared_ptr<CurlHolder> GetCurlHolder();
|
std::shared_ptr<CurlHolder> GetCurlHolder();
|
||||||
|
|
||||||
private:
|
void PrepareDelete();
|
||||||
|
void PrepareGet();
|
||||||
|
void PrepareHead();
|
||||||
|
void PrepareOptions();
|
||||||
|
void PreparePatch();
|
||||||
|
void PreparePost();
|
||||||
|
void PreparePut();
|
||||||
|
Response Complete(CURLcode curl_error);
|
||||||
|
|
||||||
|
protected:
|
||||||
class Impl;
|
class Impl;
|
||||||
std::unique_ptr<Impl> pimpl_;
|
std::unique_ptr<Impl> pimpl_;
|
||||||
};
|
};
|
||||||
|
31
vendor/CPR/include/cpr/ssl_options.h
vendored
31
vendor/CPR/include/cpr/ssl_options.h
vendored
@ -70,7 +70,7 @@ class VerifySsl {
|
|||||||
public:
|
public:
|
||||||
VerifySsl() = default;
|
VerifySsl() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
VerifySsl(bool verify) : verify(verify) {}
|
VerifySsl(bool p_verify) : verify(p_verify) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return verify;
|
return verify;
|
||||||
@ -140,6 +140,14 @@ class DerKey : public KeyFile {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PinnedPublicKey {
|
||||||
|
public:
|
||||||
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
|
PinnedPublicKey(std::string&& p_pinned_public_key) : pinned_public_key(std::move(p_pinned_public_key)) {}
|
||||||
|
|
||||||
|
const std::string pinned_public_key;
|
||||||
|
};
|
||||||
|
|
||||||
#if SUPPORT_ALPN
|
#if SUPPORT_ALPN
|
||||||
// This option enables/disables ALPN in the SSL handshake (if the SSL backend libcurl is built to
|
// This option enables/disables ALPN in the SSL handshake (if the SSL backend libcurl is built to
|
||||||
// use supports it), which can be used to negotiate http2.
|
// use supports it), which can be used to negotiate http2.
|
||||||
@ -147,7 +155,7 @@ class ALPN {
|
|||||||
public:
|
public:
|
||||||
ALPN() = default;
|
ALPN() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
ALPN(bool enabled) : enabled(enabled) {}
|
ALPN(bool p_enabled) : enabled(p_enabled) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -164,7 +172,7 @@ class NPN {
|
|||||||
public:
|
public:
|
||||||
NPN() = default;
|
NPN() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
NPN(bool enabled) : enabled(enabled) {}
|
NPN(bool p_enabled) : enabled(p_enabled) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -180,7 +188,7 @@ class VerifyHost {
|
|||||||
public:
|
public:
|
||||||
VerifyHost() = default;
|
VerifyHost() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
VerifyHost(bool enabled) : enabled(enabled) {}
|
VerifyHost(bool p_enabled) : enabled(p_enabled) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -194,7 +202,7 @@ class VerifyPeer {
|
|||||||
public:
|
public:
|
||||||
VerifyPeer() = default;
|
VerifyPeer() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
VerifyPeer(bool enabled) : enabled(enabled) {}
|
VerifyPeer(bool p_enabled) : enabled(p_enabled) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -208,7 +216,7 @@ class VerifyPeer {
|
|||||||
class VerifyStatus {
|
class VerifyStatus {
|
||||||
public:
|
public:
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
VerifyStatus(bool enabled) : enabled(enabled) {}
|
VerifyStatus(bool p_enabled) : enabled(p_enabled) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -318,7 +326,7 @@ class SessionIdCache {
|
|||||||
public:
|
public:
|
||||||
SessionIdCache() = default;
|
SessionIdCache() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
SessionIdCache(bool enabled) : enabled(enabled) {}
|
SessionIdCache(bool p_enabled) : enabled(p_enabled) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -333,7 +341,7 @@ class SslFastStart {
|
|||||||
public:
|
public:
|
||||||
SslFastStart() = default;
|
SslFastStart() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
SslFastStart(bool enabled) : enabled(enabled) {}
|
SslFastStart(bool p_enabled) : enabled(p_enabled) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -347,7 +355,7 @@ class NoRevoke {
|
|||||||
public:
|
public:
|
||||||
NoRevoke() = default;
|
NoRevoke() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
NoRevoke(bool enabled) : enabled(enabled) {}
|
NoRevoke(bool p_enabled) : enabled(p_enabled) {}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -364,6 +372,7 @@ struct SslOptions {
|
|||||||
std::string key_file;
|
std::string key_file;
|
||||||
std::string key_type;
|
std::string key_type;
|
||||||
std::string key_pass;
|
std::string key_pass;
|
||||||
|
std::string pinned_public_key;
|
||||||
#if SUPPORT_ALPN
|
#if SUPPORT_ALPN
|
||||||
bool enable_alpn = true;
|
bool enable_alpn = true;
|
||||||
#endif // SUPPORT_ALPN
|
#endif // SUPPORT_ALPN
|
||||||
@ -400,6 +409,10 @@ struct SslOptions {
|
|||||||
key_type = opt.GetKeyType();
|
key_type = opt.GetKeyType();
|
||||||
key_pass = opt.password;
|
key_pass = opt.password;
|
||||||
}
|
}
|
||||||
|
void SetOption(const ssl::PinnedPublicKey& opt) {
|
||||||
|
pinned_public_key = opt.pinned_public_key;
|
||||||
|
}
|
||||||
|
|
||||||
#if SUPPORT_ALPN
|
#if SUPPORT_ALPN
|
||||||
void SetOption(const ssl::ALPN& opt) {
|
void SetOption(const ssl::ALPN& opt) {
|
||||||
enable_alpn = opt.enabled;
|
enable_alpn = opt.enabled;
|
||||||
|
2
vendor/CPR/include/cpr/verbose.h
vendored
2
vendor/CPR/include/cpr/verbose.h
vendored
@ -7,7 +7,7 @@ class Verbose {
|
|||||||
public:
|
public:
|
||||||
Verbose() = default;
|
Verbose() = default;
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||||
Verbose(const bool verbose) : verbose{verbose} {}
|
Verbose(const bool p_verbose) : verbose{p_verbose} {}
|
||||||
|
|
||||||
bool verbose = true;
|
bool verbose = true;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user