mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-07-05 00:17:11 +02:00
Update WIP discord and some vendors.
CPR has features disabled and PCRE is fully disabled until updated to new code.
This commit is contained in:
16
vendor/CPR/cpr/curlholder.cpp
vendored
16
vendor/CPR/cpr/curlholder.cpp
vendored
@ -2,10 +2,6 @@
|
||||
#include <cassert>
|
||||
|
||||
namespace cpr {
|
||||
// It does not make sense to make a std::mutex const.
|
||||
// NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables)
|
||||
std::mutex CurlHolder::curl_easy_init_mutex_{};
|
||||
|
||||
CurlHolder::CurlHolder() {
|
||||
/**
|
||||
* Allow multithreaded access to CPR by locking curl_easy_init().
|
||||
@ -14,22 +10,24 @@ CurlHolder::CurlHolder() {
|
||||
* https://curl.haxx.se/libcurl/c/curl_easy_init.html
|
||||
* https://curl.haxx.se/libcurl/c/threadsafe.html
|
||||
**/
|
||||
curl_easy_init_mutex_.lock();
|
||||
curl_easy_init_mutex_().lock();
|
||||
// NOLINTNEXTLINE (cppcoreguidelines-prefer-member-initializer) since we need it to happen inside the lock
|
||||
handle = curl_easy_init();
|
||||
curl_easy_init_mutex_.unlock();
|
||||
curl_easy_init_mutex_().unlock();
|
||||
|
||||
assert(handle);
|
||||
} // namespace cpr
|
||||
|
||||
CurlHolder::~CurlHolder() {
|
||||
curl_slist_free_all(chunk);
|
||||
curl_formfree(formpost);
|
||||
curl_slist_free_all(resolveCurlList);
|
||||
curl_mime_free(multipart);
|
||||
curl_easy_cleanup(handle);
|
||||
}
|
||||
|
||||
std::string CurlHolder::urlEncode(const std::string& s) const {
|
||||
assert(handle);
|
||||
char* output = curl_easy_escape(handle, s.c_str(), s.length());
|
||||
char* output = curl_easy_escape(handle, s.c_str(), static_cast<int>(s.length()));
|
||||
if (output) {
|
||||
std::string result = output;
|
||||
curl_free(output);
|
||||
@ -40,7 +38,7 @@ std::string CurlHolder::urlEncode(const std::string& s) const {
|
||||
|
||||
std::string CurlHolder::urlDecode(const std::string& s) const {
|
||||
assert(handle);
|
||||
char* output = curl_easy_unescape(handle, s.c_str(), s.length(), nullptr);
|
||||
char* output = curl_easy_unescape(handle, s.c_str(), static_cast<int>(s.length()), nullptr);
|
||||
if (output) {
|
||||
std::string result = output;
|
||||
curl_free(output);
|
||||
|
Reference in New Issue
Block a user