mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Remove CURL/CPR.
This commit is contained in:
parent
fc9419677f
commit
0d05273f3f
@ -58,7 +58,6 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
||||
Library/Chrono/Time.cpp Library/Chrono/Time.hpp
|
||||
Library/Chrono/Timer.cpp Library/Chrono/Timer.hpp
|
||||
Library/Chrono/Timestamp.cpp Library/Chrono/Timestamp.hpp
|
||||
Library/CURL.cpp Library/CURL.hpp
|
||||
Library/IO.cpp Library/IO.hpp
|
||||
Library/IO/Buffer.cpp Library/IO/Buffer.hpp
|
||||
Library/IO/File.cpp Library/IO/File.hpp
|
||||
@ -108,7 +107,7 @@ if(WIN32 OR MINGW)
|
||||
target_link_libraries(SqModule wsock32 ws2_32 shlwapi)
|
||||
endif()
|
||||
# Link to base libraries
|
||||
target_link_libraries(SqModule Squirrel FmtLib SimpleINI TinyDir ConcurrentQueue cpr maxminddb libzmq-static)
|
||||
target_link_libraries(SqModule Squirrel FmtLib SimpleINI TinyDir ConcurrentQueue maxminddb libzmq-static)
|
||||
# Link to POCO libraries
|
||||
target_link_libraries(SqModule Poco::Foundation Poco::Encodings Poco::Crypto Poco::Util Poco::Data Poco::Net Poco::JSON Poco::XML Poco::Zip Poco::JWT Poco::Redis Poco::MongoDB)
|
||||
# Does POCO have SQLite support?
|
||||
|
@ -1,376 +0,0 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/CURL.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <sqratConst.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQMOD_DECL_TYPENAME(SqCpSslOptions, _SC("SqCprSslOptions"))
|
||||
SQMOD_DECL_TYPENAME(SqCpError, _SC("SqCpError"))
|
||||
SQMOD_DECL_TYPENAME(SqCpCookies, _SC("SqCprCookies"))
|
||||
SQMOD_DECL_TYPENAME(SqCpHeader, _SC("SqCprHeader"))
|
||||
SQMOD_DECL_TYPENAME(SqCpResponse, _SC("SqCprResponse"))
|
||||
SQMOD_DECL_TYPENAME(SqCpParameters, _SC("SqCprParameters"))
|
||||
SQMOD_DECL_TYPENAME(SqCpPayload, _SC("SqCprPayload"))
|
||||
SQMOD_DECL_TYPENAME(SqCpProxies, _SC("SqCprProxies"))
|
||||
SQMOD_DECL_TYPENAME(SqCpSession, _SC("SqCprSession"))
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_ErrorCodes[] = {
|
||||
{_SC("OK"), SQInteger(cpr::ErrorCode::OK)},
|
||||
{_SC("CONNECTION_FAILURE"), SQInteger(cpr::ErrorCode::CONNECTION_FAILURE)},
|
||||
{_SC("EMPTY_RESPONSE"), SQInteger(cpr::ErrorCode::EMPTY_RESPONSE)},
|
||||
{_SC("HOST_RESOLUTION_FAILURE"), SQInteger(cpr::ErrorCode::HOST_RESOLUTION_FAILURE)},
|
||||
{_SC("INTERNAL_ERROR"), SQInteger(cpr::ErrorCode::INTERNAL_ERROR)},
|
||||
{_SC("INVALID_URL_FORMAT"), SQInteger(cpr::ErrorCode::INVALID_URL_FORMAT)},
|
||||
{_SC("NETWORK_RECEIVE_ERROR"), SQInteger(cpr::ErrorCode::NETWORK_RECEIVE_ERROR)},
|
||||
{_SC("NETWORK_SEND_FAILURE"), SQInteger(cpr::ErrorCode::NETWORK_SEND_FAILURE)},
|
||||
{_SC("OPERATION_TIMEDOUT"), SQInteger(cpr::ErrorCode::OPERATION_TIMEDOUT)},
|
||||
{_SC("PROXY_RESOLUTION_FAILURE"), SQInteger(cpr::ErrorCode::PROXY_RESOLUTION_FAILURE)},
|
||||
{_SC("SSL_CONNECT_ERROR"), SQInteger(cpr::ErrorCode::SSL_CONNECT_ERROR)},
|
||||
{_SC("SSL_LOCAL_CERTIFICATE_ERROR"), SQInteger(cpr::ErrorCode::SSL_LOCAL_CERTIFICATE_ERROR)},
|
||||
{_SC("SSL_REMOTE_CERTIFICATE_ERROR"), SQInteger(cpr::ErrorCode::SSL_REMOTE_CERTIFICATE_ERROR)},
|
||||
{_SC("SSL_CACERT_ERROR"), SQInteger(cpr::ErrorCode::SSL_CACERT_ERROR)},
|
||||
{_SC("GENERIC_SSL_ERROR"), SQInteger(cpr::ErrorCode::GENERIC_SSL_ERROR)},
|
||||
{_SC("UNSUPPORTED_PROTOCOL"), SQInteger(cpr::ErrorCode::UNSUPPORTED_PROTOCOL)},
|
||||
{_SC("REQUEST_CANCELLED"), SQInteger(cpr::ErrorCode::REQUEST_CANCELLED)},
|
||||
{_SC("UNKNOWN_ERROR"), SQInteger(cpr::ErrorCode::UNKNOWN_ERROR)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_StatusCodes[] = {
|
||||
// Information responses
|
||||
{_SC("HTTP_CONTINUE"), cpr::status::HTTP_CONTINUE},
|
||||
{_SC("HTTP_SWITCHING_PROTOCOL"), cpr::status::HTTP_SWITCHING_PROTOCOL},
|
||||
{_SC("HTTP_PROCESSING"), cpr::status::HTTP_PROCESSING},
|
||||
{_SC("HTTP_EARLY_HINTS"), cpr::status::HTTP_EARLY_HINTS},
|
||||
// Successful responses
|
||||
{_SC("HTTP_OK"), cpr::status::HTTP_OK},
|
||||
{_SC("HTTP_CREATED"), cpr::status::HTTP_CREATED},
|
||||
{_SC("HTTP_ACCEPTED"), cpr::status::HTTP_ACCEPTED},
|
||||
{_SC("HTTP_NON_AUTHORITATIVE_INFORMATION"), cpr::status::HTTP_NON_AUTHORITATIVE_INFORMATION},
|
||||
{_SC("HTTP_NO_CONTENT"), cpr::status::HTTP_NO_CONTENT},
|
||||
{_SC("HTTP_RESET_CONTENT"), cpr::status::HTTP_RESET_CONTENT},
|
||||
{_SC("HTTP_PARTIAL_CONTENT"), cpr::status::HTTP_PARTIAL_CONTENT},
|
||||
{_SC("HTTP_MULTI_STATUS"), cpr::status::HTTP_MULTI_STATUS},
|
||||
{_SC("HTTP_ALREADY_REPORTED"), cpr::status::HTTP_ALREADY_REPORTED},
|
||||
{_SC("HTTP_IM_USED"), cpr::status::HTTP_IM_USED},
|
||||
// Redirection messages
|
||||
{_SC("HTTP_MULTIPLE_CHOICE"), cpr::status::HTTP_MULTIPLE_CHOICE},
|
||||
{_SC("HTTP_MOVED_PERMANENTLY"), cpr::status::HTTP_MOVED_PERMANENTLY},
|
||||
{_SC("HTTP_FOUND"), cpr::status::HTTP_FOUND},
|
||||
{_SC("HTTP_SEE_OTHER"), cpr::status::HTTP_SEE_OTHER},
|
||||
{_SC("HTTP_NOT_MODIFIED"), cpr::status::HTTP_NOT_MODIFIED},
|
||||
{_SC("HTTP_USE_PROXY"), cpr::status::HTTP_USE_PROXY},
|
||||
{_SC("HTTP_UNUSED"), cpr::status::HTTP_UNUSED},
|
||||
{_SC("HTTP_TEMPORARY_REDIRECT"), cpr::status::HTTP_TEMPORARY_REDIRECT},
|
||||
{_SC("HTTP_PERMANENT_REDIRECT"), cpr::status::HTTP_PERMANENT_REDIRECT},
|
||||
// Client error responses
|
||||
{_SC("HTTP_BAD_REQUEST"), cpr::status::HTTP_BAD_REQUEST},
|
||||
{_SC("HTTP_UNAUTHORIZED"), cpr::status::HTTP_UNAUTHORIZED},
|
||||
{_SC("HTTP_PAYMENT_REQUIRED"), cpr::status::HTTP_PAYMENT_REQUIRED},
|
||||
{_SC("HTTP_FORBIDDEN"), cpr::status::HTTP_FORBIDDEN},
|
||||
{_SC("HTTP_NOT_FOUND"), cpr::status::HTTP_NOT_FOUND},
|
||||
{_SC("HTTP_METHOD_NOT_ALLOWED"), cpr::status::HTTP_METHOD_NOT_ALLOWED},
|
||||
{_SC("HTTP_NOT_ACCEPTABLE"), cpr::status::HTTP_NOT_ACCEPTABLE},
|
||||
{_SC("HTTP_PROXY_AUTHENTICATION_REQUIRED"), cpr::status::HTTP_PROXY_AUTHENTICATION_REQUIRED},
|
||||
{_SC("HTTP_REQUEST_TIMEOUT"), cpr::status::HTTP_REQUEST_TIMEOUT},
|
||||
{_SC("HTTP_CONFLICT"), cpr::status::HTTP_CONFLICT},
|
||||
{_SC("HTTP_GONE"), cpr::status::HTTP_GONE},
|
||||
{_SC("HTTP_LENGTH_REQUIRED"), cpr::status::HTTP_LENGTH_REQUIRED},
|
||||
{_SC("HTTP_PRECONDITION_FAILED"), cpr::status::HTTP_PRECONDITION_FAILED},
|
||||
{_SC("HTTP_PAYLOAD_TOO_LARGE"), cpr::status::HTTP_PAYLOAD_TOO_LARGE},
|
||||
{_SC("HTTP_URI_TOO_LONG"), cpr::status::HTTP_URI_TOO_LONG},
|
||||
{_SC("HTTP_UNSUPPORTED_MEDIA_TYPE"), cpr::status::HTTP_UNSUPPORTED_MEDIA_TYPE},
|
||||
{_SC("HTTP_REQUESTED_RANGE_NOT_SATISFIABLE"), cpr::status::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE},
|
||||
{_SC("HTTP_EXPECTATION_FAILED"), cpr::status::HTTP_EXPECTATION_FAILED},
|
||||
{_SC("HTTP_IM_A_TEAPOT"), cpr::status::HTTP_IM_A_TEAPOT},
|
||||
{_SC("HTTP_MISDIRECTED_REQUEST"), cpr::status::HTTP_MISDIRECTED_REQUEST},
|
||||
{_SC("HTTP_UNPROCESSABLE_ENTITY"), cpr::status::HTTP_UNPROCESSABLE_ENTITY},
|
||||
{_SC("HTTP_LOCKED"), cpr::status::HTTP_LOCKED},
|
||||
{_SC("HTTP_FAILED_DEPENDENCY"), cpr::status::HTTP_FAILED_DEPENDENCY},
|
||||
{_SC("HTTP_TOO_EARLY"), cpr::status::HTTP_TOO_EARLY},
|
||||
{_SC("HTTP_UPGRADE_REQUIRED"), cpr::status::HTTP_UPGRADE_REQUIRED},
|
||||
{_SC("HTTP_PRECONDITION_REQUIRED"), cpr::status::HTTP_PRECONDITION_REQUIRED},
|
||||
{_SC("HTTP_TOO_MANY_REQUESTS"), cpr::status::HTTP_TOO_MANY_REQUESTS},
|
||||
{_SC("HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE"), cpr::status::HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE},
|
||||
{_SC("HTTP_UNAVAILABLE_FOR_LEGAL_REASONS"), cpr::status::HTTP_UNAVAILABLE_FOR_LEGAL_REASONS},
|
||||
// Server response errors
|
||||
{_SC("HTTP_INTERNAL_SERVER_ERROR"), cpr::status::HTTP_INTERNAL_SERVER_ERROR},
|
||||
{_SC("HTTP_NOT_IMPLEMENTED"), cpr::status::HTTP_NOT_IMPLEMENTED},
|
||||
{_SC("HTTP_BAD_GATEWAY"), cpr::status::HTTP_BAD_GATEWAY},
|
||||
{_SC("HTTP_SERVICE_UNAVAILABLE"), cpr::status::HTTP_SERVICE_UNAVAILABLE},
|
||||
{_SC("HTTP_GATEWAY_TIMEOUT"), cpr::status::HTTP_GATEWAY_TIMEOUT},
|
||||
{_SC("HTTP_HTTP_VERSION_NOT_SUPPORTED"), cpr::status::HTTP_HTTP_VERSION_NOT_SUPPORTED},
|
||||
{_SC("HTTP_VARIANT_ALSO_NEGOTIATES"), cpr::status::HTTP_VARIANT_ALSO_NEGOTIATES},
|
||||
{_SC("HTTP_INSUFFICIENT_STORAGE"), cpr::status::HTTP_INSUFFICIENT_STORAGE},
|
||||
{_SC("HTTP_LOOP_DETECTED"), cpr::status::HTTP_LOOP_DETECTED},
|
||||
{_SC("HTTP_NOT_EXTENDED"), cpr::status::HTTP_NOT_EXTENDED},
|
||||
{_SC("HTTP_NETWORK_AUTHENTICATION_REQUIRED"), cpr::status::HTTP_NETWORK_AUTHENTICATION_REQUIRED},
|
||||
|
||||
{_SC("INFO_CODE_OFFSET"), cpr::status::INFO_CODE_OFFSET},
|
||||
{_SC("SUCCESS_CODE_OFFSET"), cpr::status::SUCCESS_CODE_OFFSET},
|
||||
{_SC("REDIRECT_CODE_OFFSET"), cpr::status::REDIRECT_CODE_OFFSET},
|
||||
{_SC("CLIENT_ERROR_CODE_OFFSET"), cpr::status::CLIENT_ERROR_CODE_OFFSET},
|
||||
{_SC("SERVER_ERROR_CODE_OFFSET"), cpr::status::SERVER_ERROR_CODE_OFFSET},
|
||||
{_SC("MISC_CODE_OFFSET"), cpr::status::MISC_CODE_OFFSET}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElements g_EnumList[] = {
|
||||
{_SC("SqCprErrorCode"), g_ErrorCodes},
|
||||
{_SC("SqCprStatusCode"), g_StatusCodes}
|
||||
};
|
||||
|
||||
// ================================================================================================
|
||||
void Register_CURL(HSQUIRRELVM vm)
|
||||
{
|
||||
Table cpns(vm);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("SslOptions"),
|
||||
Class< CpSslOptions >(vm, SqCpSslOptions::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpSslOptions::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("CertFile"), &CpSslOptions::GetCertFile)
|
||||
.Prop(_SC("CertType"), &CpSslOptions::GetCertType, &CpSslOptions::SetCertType)
|
||||
.Prop(_SC("KeyFile"), &CpSslOptions::GetKeyFile)
|
||||
.Prop(_SC("KeyType"), &CpSslOptions::GetKeyType, &CpSslOptions::SetKeyType)
|
||||
.Prop(_SC("KeyPass"), &CpSslOptions::GetKeyPass, &CpSslOptions::SetKeyPass)
|
||||
.Prop(_SC("ALPN"), &CpSslOptions::GetALPN, &CpSslOptions::SetALPN)
|
||||
.Prop(_SC("NPM"), &CpSslOptions::GetNPM, &CpSslOptions::SetNPM)
|
||||
.Prop(_SC("VerifyHost"), &CpSslOptions::GetVerifyHost, &CpSslOptions::SetVerifyHost)
|
||||
.Prop(_SC("VerifyPeer"), &CpSslOptions::GetVerifyPeer, &CpSslOptions::SetVerifyPeer)
|
||||
.Prop(_SC("VerifyStatus"), &CpSslOptions::GetVerifyStatus, &CpSslOptions::SetVerifyStatus)
|
||||
.Prop(_SC("SslVersion"), &CpSslOptions::GetSslVersion)
|
||||
.Prop(_SC("MaxVersion"), &CpSslOptions::GetMaxVersion)
|
||||
.Prop(_SC("CaInfo"), &CpSslOptions::GetCaInfo, &CpSslOptions::SetCaInfo)
|
||||
.Prop(_SC("CaPath"), &CpSslOptions::GetCaPath, &CpSslOptions::SetCaPath)
|
||||
.Prop(_SC("CrlFile"), &CpSslOptions::GetCrlFile, &CpSslOptions::SetCrlFile)
|
||||
.Prop(_SC("Ciphers"), &CpSslOptions::GetCiphers, &CpSslOptions::SetCiphers)
|
||||
.Prop(_SC("TLS13Ciphers"), &CpSslOptions::GetTLS13Ciphers, &CpSslOptions::SetTLS13Ciphers)
|
||||
.Prop(_SC("SessionIdCache"), &CpSslOptions::GetSessionIdCache, &CpSslOptions::SetSessionIdCache)
|
||||
// Member Methods
|
||||
.Func(_SC("SetCertFile"), &CpSslOptions::SetCertFile)
|
||||
.Func(_SC("SetPemCertFile"), &CpSslOptions::SetPemCertFile)
|
||||
.Func(_SC("SetDerCertFile"), &CpSslOptions::SetDerCertFile)
|
||||
.Func(_SC("SetKeyFile"), &CpSslOptions::SetKeyFile)
|
||||
.Func(_SC("SetPemKeyFile"), &CpSslOptions::SetPemKeyFile)
|
||||
.Func(_SC("SetDerKeyFile"), &CpSslOptions::SetDerKeyFile)
|
||||
.Func(_SC("SetTLSv1"), &CpSslOptions::SetTLSv1)
|
||||
.Func(_SC("SetSSLv2"), &CpSslOptions::SetSSLv2)
|
||||
.Func(_SC("SetSSLv3"), &CpSslOptions::SetSSLv3)
|
||||
.Func(_SC("SetTLSv1_0"), &CpSslOptions::SetTLSv1_0)
|
||||
.Func(_SC("SetTLSv1_1"), &CpSslOptions::SetTLSv1_1)
|
||||
.Func(_SC("SetTLSv1_2"), &CpSslOptions::SetTLSv1_2)
|
||||
.Func(_SC("SetTLSv1_3"), &CpSslOptions::SetTLSv1_3)
|
||||
.Func(_SC("SetMaxTLSVersion"), &CpSslOptions::SetMaxTLSVersion)
|
||||
.Func(_SC("SetMaxTLSv1_0"), &CpSslOptions::SetMaxTLSv1_0)
|
||||
.Func(_SC("SetMaxTLSv1_1"), &CpSslOptions::SetMaxTLSv1_1)
|
||||
.Func(_SC("SetMaxTLSv1_2"), &CpSslOptions::SetMaxTLSv1_2)
|
||||
.Func(_SC("SetMaxTLSv1_3"), &CpSslOptions::SetMaxTLSv1_3)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("Error"),
|
||||
Class< CpError >(vm, SqCpError::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< SQInteger, StackStrF & >()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpError::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("Code"), &CpError::GetCode, &CpError::SetCode)
|
||||
.Prop(_SC("Message"), &CpError::GetMessage, &CpError::SetMessage)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("Cookies"),
|
||||
Class< CpCookies >(vm, SqCpCookies::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< bool >()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpCookies::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("Size"), &CpCookies::Size)
|
||||
.Prop(_SC("Empty"), &CpCookies::Empty)
|
||||
// Member Methods
|
||||
.FmtFunc(_SC("Count"), &CpCookies::Count)
|
||||
.FmtFunc(_SC("Erase"), &CpCookies::Erase)
|
||||
.FmtFunc(_SC("Has"), &CpCookies::Has)
|
||||
.FmtFunc(_SC("Get"), &CpCookies::Get)
|
||||
.FmtFunc(_SC("Set"), &CpCookies::Set)
|
||||
.CbFunc(_SC("Each"), &CpCookies::Each)
|
||||
.CbFunc(_SC("While"), &CpCookies::While)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("Header"),
|
||||
Class< CpHeader >(vm, SqCpHeader::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpHeader::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("Size"), &CpHeader::Size)
|
||||
.Prop(_SC("Empty"), &CpHeader::Empty)
|
||||
// Member Methods
|
||||
.FmtFunc(_SC("Count"), &CpHeader::Count)
|
||||
.FmtFunc(_SC("Erase"), &CpHeader::Erase)
|
||||
.FmtFunc(_SC("Has"), &CpHeader::Has)
|
||||
.FmtFunc(_SC("Get"), &CpHeader::Get)
|
||||
.FmtFunc(_SC("Set"), &CpHeader::Set)
|
||||
.CbFunc(_SC("Each"), &CpHeader::Each)
|
||||
.CbFunc(_SC("While"), &CpHeader::While)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("Response"),
|
||||
Class< CpResponse >(vm, SqCpResponse::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpResponse::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("CertInfo"), &CpResponse::GetCertInfoArray)
|
||||
.Prop(_SC("StatusCode"), &CpResponse::GetStatusCode, &CpResponse::SetStatusCode)
|
||||
.Prop(_SC("Text"), &CpResponse::GetText, &CpResponse::SetText)
|
||||
.Prop(_SC("Header"), &CpResponse::GetHeader, &CpResponse::SetHeader)
|
||||
.Prop(_SC("URL"), &CpResponse::GetURL, &CpResponse::SetURL)
|
||||
.Prop(_SC("Cookies"), &CpResponse::GetCookies, &CpResponse::SetCookies)
|
||||
.Prop(_SC("Error"), &CpResponse::GetError, &CpResponse::SetError)
|
||||
.Prop(_SC("RawHeader"), &CpResponse::GetRawHeader, &CpResponse::SetRawHeader)
|
||||
.Prop(_SC("StatusLine"), &CpResponse::GetStatusLine, &CpResponse::SetStatusLine)
|
||||
.Prop(_SC("Reason"), &CpResponse::GetReason, &CpResponse::SetReason)
|
||||
.Prop(_SC("UploadedBytes"), &CpResponse::GetUploadedBytes, &CpResponse::SetUploadedBytes)
|
||||
.Prop(_SC("DownloadedBytes"), &CpResponse::GetDownloadedBytes, &CpResponse::SetDownloadedBytes)
|
||||
.Prop(_SC("RedirectCount"), &CpResponse::GetRedirectCount, &CpResponse::SetRedirectCount)
|
||||
// Member Methods
|
||||
.FmtFunc(_SC("StealHeader"), &CpResponse::StealHeader)
|
||||
.FmtFunc(_SC("YieldHeader"), &CpResponse::YieldHeader)
|
||||
.FmtFunc(_SC("StealCookies"), &CpResponse::StealCookies)
|
||||
.FmtFunc(_SC("YieldCookies"), &CpResponse::YieldCookies)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("Parameters"),
|
||||
Class< CpParameters >(vm, SqCpParameters::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpParameters::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("Size"), &CpParameters::Size)
|
||||
.Prop(_SC("Empty"), &CpParameters::Empty)
|
||||
// Member Methods
|
||||
.FmtFunc(_SC("Count"), &CpParameters::Count)
|
||||
.FmtFunc(_SC("Erase"), &CpParameters::Erase)
|
||||
.FmtFunc(_SC("Has"), &CpParameters::Has)
|
||||
.FmtFunc(_SC("Get"), &CpParameters::Get)
|
||||
.FmtFunc(_SC("Set"), &CpParameters::Set)
|
||||
.CbFunc(_SC("Each"), &CpParameters::Each)
|
||||
.CbFunc(_SC("While"), &CpParameters::While)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("Payload"),
|
||||
Class< CpPayload >(vm, SqCpPayload::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpPayload::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("Size"), &CpPayload::Size)
|
||||
.Prop(_SC("Empty"), &CpPayload::Empty)
|
||||
// Member Methods
|
||||
.FmtFunc(_SC("Count"), &CpPayload::Count)
|
||||
.FmtFunc(_SC("Erase"), &CpPayload::Erase)
|
||||
.FmtFunc(_SC("Has"), &CpPayload::Has)
|
||||
.FmtFunc(_SC("Get"), &CpPayload::Get)
|
||||
.FmtFunc(_SC("Set"), &CpPayload::Set)
|
||||
.FmtFunc(_SC("Add"), &CpPayload::Add)
|
||||
.CbFunc(_SC("Each"), &CpPayload::Each)
|
||||
.CbFunc(_SC("While"), &CpPayload::While)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("Proxies"),
|
||||
Class< CpProxies >(vm, SqCpProxies::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpProxies::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("Size"), &CpProxies::Size)
|
||||
.Prop(_SC("Empty"), &CpProxies::Empty)
|
||||
// Member Methods
|
||||
.FmtFunc(_SC("Count"), &CpProxies::Count)
|
||||
.FmtFunc(_SC("Erase"), &CpProxies::Erase)
|
||||
.FmtFunc(_SC("Has"), &CpProxies::Has)
|
||||
.FmtFunc(_SC("Get"), &CpProxies::Get)
|
||||
.FmtFunc(_SC("Set"), &CpProxies::Set)
|
||||
.CbFunc(_SC("Each"), &CpProxies::Each)
|
||||
.CbFunc(_SC("While"), &CpProxies::While)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
cpns.Bind(_SC("Session"),
|
||||
Class< CpSession, NoCopy< CpSession > >(vm, SqCpSession::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqCpSession::Fn)
|
||||
// Member Methods
|
||||
.FmtFunc(_SC("SetURL"), &CpSession::SetURL_)
|
||||
.Func(_SC("SetParameters"), &CpSession::SetParameters_)
|
||||
.Func(_SC("YieldParameters"), &CpSession::YieldParameters)
|
||||
.Func(_SC("SetHeader"), &CpSession::SetHeader_)
|
||||
.Func(_SC("SetTimeout"), &CpSession::SetTimeout_)
|
||||
.Func(_SC("SetConnectTimeout"), &CpSession::SetConnectTimeout_)
|
||||
.FmtFunc(_SC("SetAuth"), &CpSession::SetAuth_)
|
||||
.FmtFunc(_SC("SetDigest"), &CpSession::SetDigest_)
|
||||
.FmtFunc(_SC("SetUserAgent"), &CpSession::SetUserAgent_)
|
||||
.Func(_SC("SetPayload"), &CpSession::SetPayload_)
|
||||
.Func(_SC("YieldPayload"), &CpSession::YieldPayload)
|
||||
.Func(_SC("SetProxies"), &CpSession::SetProxies_)
|
||||
.Func(_SC("YieldProxies"), &CpSession::YieldProxies)
|
||||
.FmtFunc(_SC("SetNTLM"), &CpSession::SetNTLM_)
|
||||
.Func(_SC("SetRedirect"), &CpSession::SetRedirect_)
|
||||
.Func(_SC("SetMaxRedirects"), &CpSession::SetMaxRedirects_)
|
||||
.Func(_SC("SetCookies"), &CpSession::SetCookies_)
|
||||
.FmtFunc(_SC("SetBody"), &CpSession::SetBody_)
|
||||
.Func(_SC("SetLowSpeed"), &CpSession::SetLowSpeed_)
|
||||
.Func(_SC("SetVerifySsl"), &CpSession::SetVerifySsl_)
|
||||
.Func(_SC("SetUnixSocket"), &CpSession::SetUnixSocket_)
|
||||
.Func(_SC("SetSslOptions"), &CpSession::SetSslOptions_)
|
||||
.FmtFunc(_SC("SetVerbose"), &CpSession::SetVerbose_)
|
||||
.Func(_SC("Delete"), &CpSession::DoDelete)
|
||||
.Func(_SC("Get"), &CpSession::DoGet)
|
||||
.Func(_SC("Head"), &CpSession::DoHead)
|
||||
.Func(_SC("Options"), &CpSession::DoOptions)
|
||||
.Func(_SC("Patch"), &CpSession::DoPatch)
|
||||
.Func(_SC("Post"), &CpSession::DoPost)
|
||||
.Func(_SC("Put"), &CpSession::DoPut)
|
||||
);
|
||||
|
||||
RootTable(vm).Bind(_SC("SqCPR"), cpns);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
RegisterEnumerations(vm, g_EnumList);
|
||||
|
||||
RootTable(vm)
|
||||
.Func(_SC("IsInformationalStatus"), cpr::status::is_informational)
|
||||
.Func(_SC("IsSuccessStatus"), cpr::status::is_success)
|
||||
.Func(_SC("IsRedirectStatus"), cpr::status::is_redirect)
|
||||
.Func(_SC("IsClientErrorStatus"), cpr::status::is_client_error)
|
||||
.Func(_SC("IsServerErrorStatus"), cpr::status::is_server_error);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,6 @@ extern void Register_CVehicle(HSQUIRRELVM vm);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
extern void Register_Chrono(HSQUIRRELVM vm);
|
||||
extern void Register_CURL(HSQUIRRELVM vm);
|
||||
extern void Register_IO(HSQUIRRELVM vm);
|
||||
extern void Register_Numeric(HSQUIRRELVM vm);
|
||||
extern void Register_String(HSQUIRRELVM vm);
|
||||
@ -82,7 +81,6 @@ bool RegisterAPI(HSQUIRRELVM vm)
|
||||
Register_CVehicle(vm);
|
||||
|
||||
Register_Chrono(vm);
|
||||
Register_CURL(vm);
|
||||
Register_IO(vm);
|
||||
Register_Numeric(vm);
|
||||
Register_String(vm);
|
||||
|
5
vendor/CMakeLists.txt
vendored
5
vendor/CMakeLists.txt
vendored
@ -6,11 +6,6 @@ add_subdirectory(TinyDir)
|
||||
set(BUILD_TESTING OFF CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
|
||||
add_subdirectory(MaxmindDB)
|
||||
set(USE_SYSTEM_CURL ON CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_CPR_TESTS OFF CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_CPR_TESTS_SSL OFF CACHE INTERNAL "" FORCE)
|
||||
set(GENERATE_COVERAGE OFF CACHE INTERNAL "" FORCE)
|
||||
add_subdirectory(CPR)
|
||||
#set(POCO_STATIC ON CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
|
||||
set(ENABLE_FOUNDATION ON CACHE INTERNAL "" FORCE)
|
||||
|
266
vendor/CPR/CMakeLists.txt
vendored
266
vendor/CPR/CMakeLists.txt
vendored
@ -1,266 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(cpr VERSION 1.5.1 LANGUAGES CXX)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
|
||||
|
||||
# Avoid the dll boilerplate code for windows
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
||||
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
set(CPR_LIBRARIES cpr CACHE INTERNAL "")
|
||||
|
||||
|
||||
macro(cpr_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT)
|
||||
option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT})
|
||||
if(DEFINED ENV{${OPTION_NAME}})
|
||||
# Allow setting the option through an environment variable
|
||||
set(${OPTION_NAME} $ENV{${OPTION_NAME}})
|
||||
endif()
|
||||
if(${OPTION_NAME})
|
||||
add_definitions(-D${OPTION_NAME})
|
||||
endif()
|
||||
message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}")
|
||||
endmacro()
|
||||
|
||||
option(${BUILD_SHARED_LIBS} "Build libraries as shared libraries" OFF)
|
||||
message(STATUS "C++ Requests CMake Options")
|
||||
message(STATUS "=======================================================")
|
||||
cpr_option(USE_SYSTEM_CURL "If ON, this project will look in the system paths for an installed curl library" ON)
|
||||
cpr_option(BUILD_CPR_TESTS "Set to ON to build cpr tests." OFF)
|
||||
cpr_option(BUILD_CPR_TESTS_SSL "Set to ON to build cpr ssl tests" ${BUILD_CPR_TESTS})
|
||||
cpr_option(GENERATE_COVERAGE "Set to ON to generate coverage reports." OFF)
|
||||
cpr_option(CPR_CURL_NOSIGNAL "Set to ON to disable use of signals in libcurl." OFF)
|
||||
cpr_option(USE_SYSTEM_GTEST "If ON, this project will look in the system paths for an installed gtest library" OFF)
|
||||
cpr_option(USE_OPENSSL "Use OpenSSL code. Experimental" ON)
|
||||
cpr_option(USE_WINSSL "Use WIN_SSL backend. Experimental" OFF)
|
||||
message(STATUS "=======================================================")
|
||||
|
||||
if (USE_OPENSSL AND USE_WINSSL)
|
||||
message(FATAL_ERROR "It's only possible to use one SSL backend")
|
||||
endif()
|
||||
|
||||
if ((NOT WIN32) AND USE_WINSSL)
|
||||
message(FATAL_ERROR "Only use WINSSL with windows")
|
||||
endif()
|
||||
|
||||
|
||||
include(GNUInstallDirs)
|
||||
# Disabled to reduce CMAke requirements
|
||||
#include(FetchContent)
|
||||
include(cmake/code_coverage.cmake)
|
||||
include(cmake/sanitizer.cmake)
|
||||
include(cmake/gcc_analyze.cmake)
|
||||
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if (NOT isMultiConfig)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${ALLOWED_BUILD_TYPES}")
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
||||
elseif(NOT CMAKE_BUILD_TYPE IN_LIST ALLOWED_BUILD_TYPES)
|
||||
message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
else ()
|
||||
unset(CMAKE_BUILD_TYPE)
|
||||
foreach(TYPE ${ALLOWED_BUILD_TYPES})
|
||||
if (NOT ${TYPE} IN_LIST CMAKE_CONFIGURATION_TYPES)
|
||||
list(APPEND CMAKE_CONFIGURATION_TYPES ${TYPE})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Curl configuration
|
||||
if(USE_SYSTEM_CURL)
|
||||
find_package(CURL REQUIRED COMPONENTS HTTP HTTPS SSL )
|
||||
if (CURL_FOUND)
|
||||
set(SSL_ENABLED ON CACHE INTERNAL "" FORCE)
|
||||
else()
|
||||
find_package(CURL REQUIRED COMPONENTS HTTP)
|
||||
if(CURL_FOUND)
|
||||
set(SSL_ENABLED OFF CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(NOT USE_SYSTEM_CURL OR NOT CURL_FOUND)
|
||||
message(STATUS "Not using system Curl, using built-in curl project instead.")
|
||||
|
||||
set(BUILD_CURL_EXE OFF CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_TESTING OFF CACHE INTERNAL "" FORCE)
|
||||
set(HTTP_ONLY ON CACHE INTERNAL "" FORCE)
|
||||
|
||||
if (USE_WINSSL OR USE_OPENSSL)
|
||||
set(SSL_ENABLED ON CACHE INTERNAL "" FORCE)
|
||||
else()
|
||||
set(CURL_CA_PATH "none" CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
||||
if(USE_WINSSL)
|
||||
#set(CMAKE_USE_WINSSL ON CACHE INTERNAL "" FORCE)
|
||||
set(CMAKE_USE_SCHANNEL ON CACHE INTERNAL "" FORCE)
|
||||
set(CURL_CA_PATH "none" CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
||||
if(USE_OPENSSL)
|
||||
set(CMAKE_USE_OPENSSL ON CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
||||
# Show progress of FetchContent:
|
||||
#set(FETCHCONTENT_QUIET OFF CACHE INTERNAL "" FORCE)
|
||||
#FetchContent_Declare(curl
|
||||
# URL https://github.com/curl/curl/releases/download/curl-7_69_1/curl-7.69.1.tar.xz
|
||||
# URL_HASH SHA256=03c7d5e6697f7b7e40ada1b2256e565a555657398e6c1fcfa4cb251ccd819d4f # the file hash for curl-7.69.1.tar.xz
|
||||
# USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
|
||||
|
||||
#FetchContent_MakeAvailable(curl)
|
||||
|
||||
#### add_library(curl_int INTERFACE)
|
||||
#### target_link_libraries(curl_int INTERFACE libcurl)
|
||||
#### target_include_directories(curl_int INTERFACE ${curl_SOURCE_DIR}/include ${curl_BINARY_DIR}/include/curl)
|
||||
#### add_library(CURL::libcurl ALIAS curl_int)
|
||||
|
||||
# Group under the "external" project folder in IDEs such as Visual Studio.
|
||||
#if(BUILD_CURL_EXE)
|
||||
# set_property(TARGET curl PROPERTY FOLDER "external")
|
||||
#endif()
|
||||
|
||||
#set_property(TARGET libcurl PROPERTY FOLDER "external")
|
||||
endif()
|
||||
|
||||
# GTest configuration
|
||||
#[[
|
||||
if(BUILD_CPR_TESTS)
|
||||
if(USE_SYSTEM_GTEST)
|
||||
find_package(GTest)
|
||||
endif()
|
||||
if(NOT USE_SYSTEM_GTEST OR NOT GTEST_FOUND)
|
||||
message(STATUS "Not using system gtest, using built-in googletest project instead.")
|
||||
if(MSVC)
|
||||
# By default, GTest compiles on Windows in CRT static linkage mode. We use this
|
||||
# variable to force it into using the CRT in dynamic linkage (DLL), just as CPR
|
||||
# does.
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "Force gtest to use the shared c runtime")
|
||||
endif()
|
||||
FetchContent_Declare(googletest
|
||||
URL https://github.com/google/googletest/archive/release-1.10.0.tar.gz
|
||||
URL_HASH SHA256=9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb # the file hash for release-1.10.0.tar.gz
|
||||
USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
add_library(gtest_int INTERFACE)
|
||||
target_link_libraries(gtest_int INTERFACE gtest)
|
||||
target_include_directories(gtest_int INTERFACE ${googletest_SOURCE_DIR}/include)
|
||||
|
||||
add_library(GTest::GTest ALIAS gtest_int)
|
||||
|
||||
# Group under the "tests/gtest" project folder in IDEs such as Visual Studio.
|
||||
set_property(TARGET gtest PROPERTY FOLDER "tests/gtest")
|
||||
set_property(TARGET gtest_main PROPERTY FOLDER "tests/gtest")
|
||||
endif()
|
||||
endif()
|
||||
]]
|
||||
|
||||
|
||||
# Mongoose configuration
|
||||
#[[
|
||||
if(BUILD_CPR_TESTS)
|
||||
message(STATUS "Building mongoose project for test support.")
|
||||
if (SSL_ENABLED)
|
||||
find_package(OpenSSL)
|
||||
if (OPENSSL_FOUND)
|
||||
set(ENABLE_SSL_TESTS ${BUILD_CPR_TESTS_SSL} CACHE INTERNAL "")
|
||||
else()
|
||||
set(ENABLE_SSL_TESTS OFF CACHE INTERNAL "")
|
||||
endif()
|
||||
else()
|
||||
set(ENABLE_SSL_TESTS OFF CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(mongoose
|
||||
URL https://github.com/cesanta/mongoose/archive/6.18.tar.gz
|
||||
URL_HASH SHA256=f5c10346abc9c72f7cac7885d853ca064fb09aad57580433941a8fd7a3543769 # the hash for 6.18.tar.gz
|
||||
USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
|
||||
# We can not use FetchContent_MakeAvailable, since we need to patch mongoose to use CMake
|
||||
if (NOT mongoose_POPULATED)
|
||||
FetchContent_POPULATE(mongoose)
|
||||
|
||||
file(INSTALL cmake/mongoose.CMakeLists.txt DESTINATION ${mongoose_SOURCE_DIR})
|
||||
file(RENAME ${mongoose_SOURCE_DIR}/mongoose.CMakeLists.txt ${mongoose_SOURCE_DIR}/CMakeLists.txt)
|
||||
add_subdirectory(${mongoose_SOURCE_DIR} ${mongoose_BINARY_DIR})
|
||||
|
||||
endif()
|
||||
# Group under the "external" project folder in IDEs such as Visual Studio.
|
||||
set_property(TARGET mongoose PROPERTY FOLDER "external")
|
||||
endif()
|
||||
]]
|
||||
|
||||
add_library(cpr
|
||||
# Source files
|
||||
cpr/auth.cpp
|
||||
cpr/bearer.cpp
|
||||
cpr/cookies.cpp
|
||||
cpr/cprtypes.cpp
|
||||
cpr/curl_container.cpp
|
||||
cpr/curlholder.cpp
|
||||
cpr/error.cpp
|
||||
cpr/multipart.cpp
|
||||
cpr/parameters.cpp
|
||||
cpr/payload.cpp
|
||||
cpr/proxies.cpp
|
||||
cpr/session.cpp
|
||||
cpr/timeout.cpp
|
||||
cpr/unix_socket.cpp
|
||||
cpr/util.cpp
|
||||
cpr/response.cpp
|
||||
# Header files
|
||||
include/cpr/api.h
|
||||
include/cpr/auth.h
|
||||
include/cpr/bearer.h
|
||||
include/cpr/body.h
|
||||
include/cpr/cookies.h
|
||||
include/cpr/cpr.h
|
||||
include/cpr/cprtypes.h
|
||||
include/cpr/curlholder.h
|
||||
include/cpr/curlholder.h
|
||||
include/cpr/digest.h
|
||||
include/cpr/error.h
|
||||
include/cpr/limit_rate.h
|
||||
include/cpr/max_redirects.h
|
||||
include/cpr/multipart.h
|
||||
include/cpr/ntlm.h
|
||||
include/cpr/parameters.h
|
||||
include/cpr/payload.h
|
||||
include/cpr/proxies.h
|
||||
include/cpr/response.h
|
||||
include/cpr/session.h
|
||||
include/cpr/ssl_options.h
|
||||
include/cpr/timeout.h
|
||||
include/cpr/unix_socket.h
|
||||
include/cpr/util.h
|
||||
include/cpr/verbose.h
|
||||
)
|
||||
|
||||
add_library(cpr::cpr ALIAS cpr)
|
||||
|
||||
target_include_directories(cpr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(cpr PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
target_link_libraries(cpr PUBLIC curl) # todo should be private, but first dependencies in ssl_options need to be removed
|
||||
|
||||
# Set version for shared libraries.
|
||||
set_target_properties(cpr
|
||||
PROPERTIES
|
||||
VERSION ${${PROJECT_NAME}_VERSION}
|
||||
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR})
|
||||
|
||||
#install(DIRECTORY cpr DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
#install(TARGETS cpr)
|
||||
|
||||
#[[
|
||||
if(BUILD_CPR_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
]]
|
27
vendor/CPR/CONTRIBUTING.md
vendored
27
vendor/CPR/CONTRIBUTING.md
vendored
@ -1,27 +0,0 @@
|
||||
# Contributing to C++ Requests
|
||||
|
||||
Please fork this repository and contribute back using [pull requests](https://github.com/whoshuu/cpr/pulls). Features can be requested using [issues](https://github.com/whoshuu/cpr/issues). All code, comments, and critiques are greatly appreciated.
|
||||
|
||||
## Formatting
|
||||
|
||||
To avoid unproductive debates on formatting, this project uses `clang-format` to ensure a consistent style across all source files. Currently, `clang-format` 3.8 is the version of `clang-format` we use. The format file can be found [here](https://github.com/whoshuu/cpr/blob/master/.clang-format). To install `clang-format` on Ubuntu, run this:
|
||||
|
||||
```
|
||||
apt-get install clang-format-3.8
|
||||
```
|
||||
|
||||
To install `clang-format` on OS X, run this:
|
||||
|
||||
```
|
||||
brew install clang-format
|
||||
```
|
||||
|
||||
Note that `brew` might install a later version of `clang-format`, but it should be mostly compatible with what's run on the Travis servers.
|
||||
|
||||
To run `clang-format` on every source file, run this in the root directory:
|
||||
|
||||
```
|
||||
./format-check.sh
|
||||
```
|
||||
|
||||
This should indicate which files need formatting and also show a diff of the requested changes. More specific usage instructions can be found on the official [LLVM website](http://releases.llvm.org/3.8.0/tools/clang/docs/ClangFormat.html).
|
21
vendor/CPR/LICENSE
vendored
21
vendor/CPR/LICENSE
vendored
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Huu Nguyen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
141
vendor/CPR/README.md
vendored
141
vendor/CPR/README.md
vendored
@ -1,141 +0,0 @@
|
||||
# C++ Requests: Curl for People <img align="right" height="40" src="http://i.imgur.com/d9Xtyts.png">
|
||||
|
||||
[![Documentation](https://img.shields.io/badge/docs-online-informational?style=flat&link=https://whoshuu.github.io/cpr/)](https://whoshuu.github.io/cpr/)
|
||||
![CI](https://github.com/whoshuu/cpr/workflows/CI/badge.svg)
|
||||
|
||||
## Announcements
|
||||
|
||||
The cpr project has new maintainers: [Fabian Sauter](https://github.com/com8) and [Tim Stack](https://github.com/tstack).
|
||||
|
||||
## TLDR
|
||||
|
||||
C++ Requests is a simple wrapper around [libcurl](http://curl.haxx.se/libcurl) inspired by the excellent [Python Requests](https://github.com/kennethreitz/requests) project.
|
||||
|
||||
Despite its name, libcurl's easy interface is anything but, and making mistakes misusing it is a common source of error and frustration. Using the more expressive language facilities of C++11, this library captures the essence of making network calls into a few concise idioms.
|
||||
|
||||
Here's a quick GET request:
|
||||
|
||||
```c++
|
||||
#include <cpr/cpr.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
cpr::Response r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
|
||||
cpr::Authentication{"user", "pass"},
|
||||
cpr::Parameters{{"anon", "true"}, {"key", "value"}});
|
||||
r.status_code; // 200
|
||||
r.header["content-type"]; // application/json; charset=utf-8
|
||||
r.text; // JSON text string
|
||||
}
|
||||
```
|
||||
|
||||
And here's [less functional, more complicated code, without cpr](https://gist.github.com/whoshuu/2dc858b8730079602044).
|
||||
|
||||
## Documentation
|
||||
|
||||
[![Documentation](https://img.shields.io/badge/docs-online-informational?style=for-the-badge&link=https://whoshuu.github.io/cpr/)](https://whoshuu.github.io/cpr/)
|
||||
You can find the latest documentation [here](https://whoshuu.github.io/cpr). It's a work in progress, but it should give you a better idea of how to use the library than the [tests](https://github.com/whoshuu/cpr/tree/master/test) currently do.
|
||||
|
||||
## Features
|
||||
|
||||
C++ Requests currently supports:
|
||||
|
||||
* Custom headers
|
||||
* Url encoded parameters
|
||||
* Url encoded POST values
|
||||
* Multipart form POST upload
|
||||
* File POST upload
|
||||
* Basic authentication
|
||||
* Bearer authentication
|
||||
* Digest authentication
|
||||
* NTLM authentication
|
||||
* Connection and request timeout specification
|
||||
* Timeout for low speed connection
|
||||
* Asynchronous requests
|
||||
* :cookie: support!
|
||||
* Proxy support
|
||||
* Callback interfaces
|
||||
* PUT methods
|
||||
* DELETE methods
|
||||
* HEAD methods
|
||||
* OPTIONS methods
|
||||
* PATCH methods
|
||||
* Thread Safe access to [libCurl](https://curl.haxx.se/libcurl/c/threadsafe.html)
|
||||
* OpenSSL and WinSSL support for HTTPS requests
|
||||
|
||||
## Planned
|
||||
|
||||
For a quick overview about the planed features, have a look at the next [Milestones](https://github.com/whoshuu/cpr/milestones).
|
||||
|
||||
## Usage
|
||||
|
||||
If you already have a project you need to integrate C++ Requests with, the primary way is to use CMake `fetch_content`.
|
||||
Add the following to your `CMakeLists.txt`.
|
||||
|
||||
|
||||
```cmake
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/whoshuu/cpr.git GIT_TAG c8d33915dbd88ad6c92b258869b03aba06587ff9) # the commit hash for 1.5.0
|
||||
FetchContent_MakeAvailable(cpr)
|
||||
```
|
||||
|
||||
This will produce the target `cpr::cpr` which you can link against the typical way:
|
||||
|
||||
```cmake
|
||||
target_link_libraries(your_target_name PRIVATE cpr::cpr)
|
||||
```
|
||||
|
||||
That should do it!
|
||||
There's no need to handle `libcurl` yourself. All dependencies are taken care of for you.
|
||||
|
||||
## Requirements
|
||||
|
||||
The only explicit requirements are:
|
||||
|
||||
* a `C++11` compatible compiler such as Clang or GCC. The minimum required version of GCC is unknown, so if anyone has trouble building this library with a specific version of GCC, do let me know
|
||||
* If you would like to perform https requests `OpenSSL` and its development libraries are required.
|
||||
|
||||
## Building cpr - Using vcpkg
|
||||
|
||||
You can download and install cpr using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||
```Bash
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
./vcpkg install cpr
|
||||
```
|
||||
The `cpr` port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
## Building cpr - Using Conan
|
||||
|
||||
You can download and install `cpr` using the [Conan](https://conan.io/) package manager. Setup your CMakeLists.txt (see [Conan documentation](https://docs.conan.io/en/latest/integrations/build_system.html) on how to use MSBuild, Meson and others) like this:
|
||||
|
||||
```CMake
|
||||
project(myproject CXX)
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) # Include Conan-generated file
|
||||
conan_basic_setup(TARGETS) # Introduce Conan-generated targets
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} CONAN_PKG::cpr)
|
||||
```
|
||||
Create `conanfile.txt` in your source dir:
|
||||
```
|
||||
[requires]
|
||||
cpr/1.5.0
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
```
|
||||
Install and run Conan, then build your project as always:
|
||||
|
||||
```Bash
|
||||
pip install conan
|
||||
mkdir build
|
||||
cd build
|
||||
conan install ../ --build=missing
|
||||
cmake ../
|
||||
cmake --build .
|
||||
```
|
||||
The `cpr` package in Conan is kept up to date by Conan contributors. If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the `conan-center-index` repository.
|
29
vendor/CPR/cmake/code_coverage.cmake
vendored
29
vendor/CPR/cmake/code_coverage.cmake
vendored
@ -1,29 +0,0 @@
|
||||
# Code coverage
|
||||
if(BUILD_CPR_TESTS AND GENERATE_COVERAGE)
|
||||
set(CMAKE_BUILD_TYPE COVERAGE CACHE INTERNAL "Coverage enabled build")
|
||||
message(STATUS "Enabling gcov support")
|
||||
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(COVERAGE_FLAG "--coverage")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE
|
||||
"-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage"
|
||||
CACHE STRING "Flags used by the C++ compiler during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_C_FLAGS_COVERAGE
|
||||
"-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage"
|
||||
CACHE STRING "Flags used by the C compiler during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||
""
|
||||
CACHE STRING "Flags used for linking binaries during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
|
||||
""
|
||||
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
|
||||
FORCE)
|
||||
mark_as_advanced(
|
||||
CMAKE_CXX_FLAGS_COVERAGE
|
||||
CMAKE_C_FLAGS_COVERAGE
|
||||
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||
CMAKE_SHARED_LINKER_FLAGS_COVERAGE)
|
||||
endif()
|
12
vendor/CPR/cmake/gcc_analyze.cmake
vendored
12
vendor/CPR/cmake/gcc_analyze.cmake
vendored
@ -1,12 +0,0 @@
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
check_cxx_compiler_flag("-fanalyzer" HAS_GCC_STATIC_ANALYZER)
|
||||
if(HAS_GCC_STATIC_ANALYZER AND NOT ENABLE_LINTING)
|
||||
option(ENABLE_GCC_STATIC_ANALYZER "Enable linting with the GCC static analyzer" OFF)
|
||||
if(ENABLE_GCC_STATIC_ANALYZER)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fanalyzer")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fanalyzer")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
12
vendor/CPR/cmake/mongoose.CMakeLists.txt
vendored
12
vendor/CPR/cmake/mongoose.CMakeLists.txt
vendored
@ -1,12 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(mongoose C)
|
||||
|
||||
|
||||
add_library(mongoose STATIC mongoose.c)
|
||||
target_include_directories(mongoose PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(ENABLE_SSL_TESTS)
|
||||
# Enable mongoose SSL
|
||||
target_compile_definitions(mongoose PUBLIC MG_ENABLE_SSL)
|
||||
target_link_libraries(mongoose PRIVATE OpenSSL::SSL)
|
||||
endif()
|
65
vendor/CPR/cmake/sanitizer.cmake
vendored
65
vendor/CPR/cmake/sanitizer.cmake
vendored
@ -1,65 +0,0 @@
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CheckCXXSourceRuns)
|
||||
|
||||
set(ALLOWED_BUILD_TYPES Debug Release RelWithDebInfo MinSizeRel)
|
||||
set(ALL_SAN_FLAGS "")
|
||||
|
||||
# Thread sanitizer
|
||||
set(THREAD_SAN_FLAGS "-fsanitize=thread")
|
||||
set(PREV_FLAG ${CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_REQUIRED_FLAGS "${THREAD_SAN_FLAGS}")
|
||||
check_cxx_source_runs("int main() { return 0; }" THREAD_SANITIZER_AVAILABLE)
|
||||
set(CMAKE_REQUIRED_FLAGS ${PREV_FLAG})
|
||||
if(THREAD_SANITIZER_AVAILABLE)
|
||||
list(APPEND ALLOWED_BUILD_TYPES ThreadSan)
|
||||
# Do not add Thread sanitizer to all sanitizer because it is incompatible with other sanitizer
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS_THREADSAN "${CMAKE_C_FLAGS_DEBUG} ${THREAD_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C compiler during thread sanitizer builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_THREADSAN "${CMAKE_CXX_FLAGS_DEBUG} ${THREAD_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C++ compiler during thread sanitizer builds." FORCE)
|
||||
|
||||
# Address sanitizer
|
||||
set(ADDR_SAN_FLAGS "-fsanitize=address")
|
||||
set(PREV_FLAG ${CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_REQUIRED_FLAGS "${ADDR_SAN_FLAGS}")
|
||||
check_cxx_source_runs("int main() { return 0; }" ADDRESS_SANITIZER_AVAILABLE)
|
||||
set(CMAKE_REQUIRED_FLAGS ${PREV_FLAG})
|
||||
if(ADDRESS_SANITIZER_AVAILABLE)
|
||||
list(APPEND ALLOWED_BUILD_TYPES AddrSan)
|
||||
set(ALL_SAN_FLAGS "${ALL_SAN_FLAGS} ${ADDR_SAN_FLAGS}")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS_ADDRSAN "${CMAKE_C_FLAGS_DEBUG} ${ADDR_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C compiler during address sanitizer builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_ADDRSAN "${CMAKE_CXX_FLAGS_DEBUG} ${ADDR_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C++ compiler during address sanitizer builds." FORCE)
|
||||
|
||||
# Leak sanitizer
|
||||
set(LEAK_SAN_FLAGS "-fsanitize=leak")
|
||||
check_cxx_compiler_flag(${LEAK_SAN_FLAGS} LEAK_SANITIZER_AVAILABLE)
|
||||
if(LEAK_SANITIZER_AVAILABLE)
|
||||
list(APPEND ALLOWED_BUILD_TYPES LeakSan)
|
||||
set(ALL_SAN_FLAGS "${ALL_SAN_FLAGS} ${LEAK_SAN_FLAGS}")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS_LEAKSAN "${CMAKE_C_FLAGS_DEBUG} ${LEAK_SAN_FLAGS} -fno-omit-frame-pointer" CACHE INTERNAL "Flags used by the C compiler during leak sanitizer builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_LEAKSAN "${CMAKE_CXX_FLAGS_DEBUG} ${LEAK_SAN_FLAGS} -fno-omit-frame-pointer" CACHE INTERNAL "Flags used by the C++ compiler during leak sanitizer builds." FORCE)
|
||||
|
||||
# Undefined behavior sanitizer
|
||||
set(UDEF_SAN_FLAGS "-fsanitize=undefined")
|
||||
check_cxx_compiler_flag(${UDEF_SAN_FLAGS} UNDEFINED_BEHAVIOUR_SANITIZER_AVAILABLE)
|
||||
if(UNDEFINED_BEHAVIOUR_SANITIZER_AVAILABLE)
|
||||
list(APPEND ALLOWED_BUILD_TYPES UdefSan)
|
||||
set(ALL_SAN_FLAGS "${ALL_SAN_FLAGS} ${UDEF_SAN_FLAGS}")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS_UDEFSAN "${CMAKE_C_FLAGS_DEBUG} ${UDEF_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C compiler during undefined behaviour sanitizer builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_UDEFSAN "${CMAKE_CXX_FLAGS_DEBUG} ${UDEF_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C++ compiler during undefined behaviour sanitizer builds." FORCE)
|
||||
|
||||
# All sanitizer (without thread sanitizer)
|
||||
if(NOT ALL_SAN_FLAGS STREQUAL "")
|
||||
set(PREV_FLAG ${CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_REQUIRED_FLAGS "${ALL_SAN_FLAGS}")
|
||||
check_cxx_source_runs("int main() { return 0; }" ALL_SANITIZERS_AVAILABLE)
|
||||
set(CMAKE_REQUIRED_FLAGS ${PREV_FLAG})
|
||||
if(ALL_SANITIZERS_AVAILABLE)
|
||||
list(APPEND ALLOWED_BUILD_TYPES AllSan)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS_ALLSAN "${CMAKE_C_FLAGS_DEBUG} ${ALL_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C compiler during most possible sanitizer builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_ALLSAN "${CMAKE_CXX_FLAGS_DEBUG} ${ALL_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C++ compiler during most possible sanitizer builds." FORCE)
|
26
vendor/CPR/cpr-config.cmake
vendored
26
vendor/CPR/cpr-config.cmake
vendored
@ -1,26 +0,0 @@
|
||||
# - C++ Requests, Curl for People
|
||||
# This module is a libcurl wrapper written in modern C++.
|
||||
# It provides an easy, intuitive, and efficient interface to
|
||||
# a host of networking methods.
|
||||
#
|
||||
# Finding this module will define the following variables:
|
||||
# CPR_FOUND - True if the core library has been found
|
||||
# CPR_LIBRARIES - Path to the core library archive
|
||||
# CPR_INCLUDE_DIRS - Path to the include directories. Gives access
|
||||
# to cpr.h, which must be included in every
|
||||
# file that uses this interface
|
||||
|
||||
find_path(CPR_INCLUDE_DIR
|
||||
NAMES cpr.h)
|
||||
|
||||
find_library(CPR_LIBRARY
|
||||
NAMES cpr
|
||||
HINTS ${CPR_LIBRARY_ROOT})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CPR REQUIRED_VARS CPR_LIBRARY CPR_INCLUDE_DIR)
|
||||
|
||||
if(CPR_FOUND)
|
||||
set(CPR_LIBRARIES ${CPR_LIBRARY})
|
||||
set(CPR_INCLUDE_DIRS ${CPR_INCLUDE_DIR})
|
||||
endif()
|
7
vendor/CPR/cpr/auth.cpp
vendored
7
vendor/CPR/cpr/auth.cpp
vendored
@ -1,7 +0,0 @@
|
||||
#include "cpr/auth.h"
|
||||
|
||||
namespace cpr {
|
||||
const char* Authentication::GetAuthString() const noexcept {
|
||||
return auth_string_.c_str();
|
||||
}
|
||||
} // namespace cpr
|
11
vendor/CPR/cpr/bearer.cpp
vendored
11
vendor/CPR/cpr/bearer.cpp
vendored
@ -1,11 +0,0 @@
|
||||
#include "cpr/bearer.h"
|
||||
|
||||
namespace cpr {
|
||||
// Only supported with libcurl >= 7.61.0.
|
||||
// As an alternative use SetHeader and add the token manually.
|
||||
#if LIBCURL_VERSION_NUM >= 0x073D00
|
||||
const char* Bearer::GetToken() const noexcept {
|
||||
return token_string_.c_str();
|
||||
}
|
||||
#endif
|
||||
} // namespace cpr
|
51
vendor/CPR/cpr/cookies.cpp
vendored
51
vendor/CPR/cpr/cookies.cpp
vendored
@ -1,51 +0,0 @@
|
||||
#include "cpr/cookies.h"
|
||||
|
||||
namespace cpr {
|
||||
std::string Cookies::GetEncoded(const CurlHolder& holder) const {
|
||||
std::stringstream stream;
|
||||
for (const std::pair<const std::string, std::string>& item : map_) {
|
||||
// Depending on if encoding is set to "true", we will URL-encode cookies
|
||||
stream << (encode ? holder.urlEncode(item.first) : item.first) << "=";
|
||||
|
||||
// special case version 1 cookies, which can be distinguished by
|
||||
// beginning and trailing quotes
|
||||
if (!item.second.empty() && item.second.front() == '"' && item.second.back() == '"') {
|
||||
stream << item.second;
|
||||
} else {
|
||||
// Depending on if encoding is set to "true", we will URL-encode cookies
|
||||
stream << (encode ? holder.urlEncode(item.second) : item.second);
|
||||
}
|
||||
stream << "; ";
|
||||
}
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string& Cookies::operator[](const std::string& key) {
|
||||
return map_[key];
|
||||
}
|
||||
|
||||
Cookies::iterator Cookies::begin() {
|
||||
return map_.begin();
|
||||
}
|
||||
|
||||
Cookies::iterator Cookies::end() {
|
||||
return map_.end();
|
||||
}
|
||||
|
||||
Cookies::const_iterator Cookies::begin() const {
|
||||
return map_.begin();
|
||||
}
|
||||
|
||||
Cookies::const_iterator Cookies::end() const {
|
||||
return map_.end();
|
||||
}
|
||||
|
||||
Cookies::const_iterator Cookies::cbegin() const {
|
||||
return map_.cbegin();
|
||||
}
|
||||
|
||||
Cookies::const_iterator Cookies::cend() const {
|
||||
return map_.cend();
|
||||
}
|
||||
|
||||
} // namespace cpr
|
12
vendor/CPR/cpr/cprtypes.cpp
vendored
12
vendor/CPR/cpr/cprtypes.cpp
vendored
@ -1,12 +0,0 @@
|
||||
#include "cpr/cprtypes.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
namespace cpr {
|
||||
bool CaseInsensitiveCompare::operator()(const std::string& a, const std::string& b) const noexcept {
|
||||
return std::lexicographical_compare(
|
||||
a.begin(), a.end(), b.begin(), b.end(),
|
||||
[](unsigned char ac, unsigned char bc) { return std::tolower(ac) < std::tolower(bc); });
|
||||
}
|
||||
} // namespace cpr
|
59
vendor/CPR/cpr/curl_container.cpp
vendored
59
vendor/CPR/cpr/curl_container.cpp
vendored
@ -1,59 +0,0 @@
|
||||
#include "cpr/curl_container.h"
|
||||
|
||||
|
||||
namespace cpr {
|
||||
template <class T>
|
||||
CurlContainer<T>::CurlContainer(const std::initializer_list<T>& containerList)
|
||||
: containerList_(containerList) {}
|
||||
|
||||
template <class T>
|
||||
void CurlContainer<T>::Add(const std::initializer_list<T>& containerList) {
|
||||
for (const T& element : containerList) {
|
||||
containerList_.push_back(std::move(element));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void CurlContainer<T>::Add(const T& element) {
|
||||
containerList_.push_back(std::move(element));
|
||||
}
|
||||
|
||||
template <>
|
||||
const std::string CurlContainer<Parameter>::GetContent(const CurlHolder& holder) const {
|
||||
std::string content{};
|
||||
for (const Parameter& parameter : containerList_) {
|
||||
if (!content.empty()) {
|
||||
content += "&";
|
||||
}
|
||||
|
||||
std::string escapedKey = holder.urlEncode(parameter.key);
|
||||
if (parameter.value.empty()) {
|
||||
content += escapedKey;
|
||||
} else {
|
||||
std::string escapedValue = holder.urlEncode(parameter.value);
|
||||
content += escapedKey + "=";
|
||||
content += escapedValue;
|
||||
}
|
||||
};
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
template <>
|
||||
const std::string CurlContainer<Pair>::GetContent(const CurlHolder& holder) const {
|
||||
std::string content{};
|
||||
for (const cpr::Pair& element : containerList_) {
|
||||
if (!content.empty()) {
|
||||
content += "&";
|
||||
}
|
||||
std::string escaped = holder.urlEncode(element.value);
|
||||
content += element.key + "=" + escaped;
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
template class CurlContainer<Pair>;
|
||||
template class CurlContainer<Parameter>;
|
||||
|
||||
} // namespace cpr
|
54
vendor/CPR/cpr/curlholder.cpp
vendored
54
vendor/CPR/cpr/curlholder.cpp
vendored
@ -1,54 +0,0 @@
|
||||
#include "cpr/curlholder.h"
|
||||
#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_{};
|
||||
|
||||
#ifndef _WIN32 // There is no thread sanitizer on windows
|
||||
__attribute__((no_sanitize("thread")))
|
||||
#endif
|
||||
CurlHolder::CurlHolder() {
|
||||
/**
|
||||
* Allow multithreaded access to CPR by locking curl_easy_init().
|
||||
* curl_easy_init() is not thread safe.
|
||||
* References:
|
||||
* https://curl.haxx.se/libcurl/c/curl_easy_init.html
|
||||
* https://curl.haxx.se/libcurl/c/threadsafe.html
|
||||
**/
|
||||
curl_easy_init_mutex_.lock();
|
||||
handle = curl_easy_init();
|
||||
curl_easy_init_mutex_.unlock();
|
||||
|
||||
assert(handle);
|
||||
} // namespace cpr
|
||||
|
||||
CurlHolder::~CurlHolder() {
|
||||
curl_easy_cleanup(handle);
|
||||
curl_slist_free_all(chunk);
|
||||
curl_formfree(formpost);
|
||||
}
|
||||
|
||||
std::string CurlHolder::urlEncode(const std::string& s) const {
|
||||
assert(handle);
|
||||
char* output = curl_easy_escape(handle, s.c_str(), s.length());
|
||||
if (output) {
|
||||
std::string result = output;
|
||||
curl_free(output);
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CurlHolder::urlDecode(const std::string& s) const {
|
||||
assert(handle);
|
||||
char* output = curl_easy_unescape(handle, s.c_str(), s.length(), nullptr);
|
||||
if (output) {
|
||||
std::string result = output;
|
||||
curl_free(output);
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
} // namespace cpr
|
68
vendor/CPR/cpr/error.cpp
vendored
68
vendor/CPR/cpr/error.cpp
vendored
@ -1,68 +0,0 @@
|
||||
#include "cpr/error.h"
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
namespace cpr {
|
||||
ErrorCode Error::getErrorCodeForCurlError(std::int32_t curl_code) {
|
||||
switch (curl_code) {
|
||||
case CURLE_OK:
|
||||
return ErrorCode::OK;
|
||||
case CURLE_UNSUPPORTED_PROTOCOL:
|
||||
return ErrorCode::UNSUPPORTED_PROTOCOL;
|
||||
case CURLE_URL_MALFORMAT:
|
||||
return ErrorCode::INVALID_URL_FORMAT;
|
||||
case CURLE_COULDNT_RESOLVE_PROXY:
|
||||
return ErrorCode::PROXY_RESOLUTION_FAILURE;
|
||||
case CURLE_COULDNT_RESOLVE_HOST:
|
||||
return ErrorCode::HOST_RESOLUTION_FAILURE;
|
||||
case CURLE_COULDNT_CONNECT:
|
||||
return ErrorCode::CONNECTION_FAILURE;
|
||||
case CURLE_OPERATION_TIMEDOUT:
|
||||
return ErrorCode::OPERATION_TIMEDOUT;
|
||||
case CURLE_SSL_CONNECT_ERROR:
|
||||
return ErrorCode::SSL_CONNECT_ERROR;
|
||||
#if LIBCURL_VERSION_NUM < 0x073e00
|
||||
case CURLE_PEER_FAILED_VERIFICATION:
|
||||
return ErrorCode::SSL_REMOTE_CERTIFICATE_ERROR;
|
||||
#endif
|
||||
case CURLE_ABORTED_BY_CALLBACK:
|
||||
case CURLE_WRITE_ERROR:
|
||||
return ErrorCode::REQUEST_CANCELLED;
|
||||
case CURLE_GOT_NOTHING:
|
||||
return ErrorCode::EMPTY_RESPONSE;
|
||||
case CURLE_SSL_ENGINE_NOTFOUND:
|
||||
case CURLE_SSL_ENGINE_SETFAILED:
|
||||
return ErrorCode::GENERIC_SSL_ERROR;
|
||||
case CURLE_SEND_ERROR:
|
||||
return ErrorCode::NETWORK_SEND_FAILURE;
|
||||
case CURLE_RECV_ERROR:
|
||||
return ErrorCode::NETWORK_RECEIVE_ERROR;
|
||||
case CURLE_SSL_CERTPROBLEM:
|
||||
return ErrorCode::SSL_LOCAL_CERTIFICATE_ERROR;
|
||||
case CURLE_SSL_CIPHER:
|
||||
return ErrorCode::GENERIC_SSL_ERROR;
|
||||
#if LIBCURL_VERSION_NUM >= 0x073e00
|
||||
case CURLE_PEER_FAILED_VERIFICATION:
|
||||
return ErrorCode::SSL_REMOTE_CERTIFICATE_ERROR;
|
||||
#else
|
||||
case CURLE_SSL_CACERT:
|
||||
return ErrorCode::SSL_CACERT_ERROR;
|
||||
#endif
|
||||
case CURLE_USE_SSL_FAILED:
|
||||
case CURLE_SSL_ENGINE_INITFAILED:
|
||||
return ErrorCode::GENERIC_SSL_ERROR;
|
||||
case CURLE_SSL_CACERT_BADFILE:
|
||||
return ErrorCode::SSL_CACERT_ERROR;
|
||||
case CURLE_SSL_SHUTDOWN_FAILED:
|
||||
return ErrorCode::GENERIC_SSL_ERROR;
|
||||
case CURLE_SSL_CRL_BADFILE:
|
||||
case CURLE_SSL_ISSUER_ERROR:
|
||||
return ErrorCode::SSL_CACERT_ERROR;
|
||||
case CURLE_TOO_MANY_REDIRECTS:
|
||||
return ErrorCode::OK;
|
||||
default:
|
||||
return ErrorCode::INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cpr
|
5
vendor/CPR/cpr/multipart.cpp
vendored
5
vendor/CPR/cpr/multipart.cpp
vendored
@ -1,5 +0,0 @@
|
||||
#include "cpr/multipart.h"
|
||||
|
||||
namespace cpr {
|
||||
Multipart::Multipart(const std::initializer_list<Part>& parts) : parts{parts} {}
|
||||
} // namespace cpr
|
10
vendor/CPR/cpr/parameters.cpp
vendored
10
vendor/CPR/cpr/parameters.cpp
vendored
@ -1,10 +0,0 @@
|
||||
#include "cpr/parameters.h"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
|
||||
#include "cpr/util.h"
|
||||
|
||||
namespace cpr {
|
||||
Parameters::Parameters(const std::initializer_list<Parameter>& parameters) : CurlContainer<Parameter>(parameters) {}
|
||||
} // namespace cpr
|
10
vendor/CPR/cpr/payload.cpp
vendored
10
vendor/CPR/cpr/payload.cpp
vendored
@ -1,10 +0,0 @@
|
||||
#include "cpr/payload.h"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
|
||||
#include "cpr/util.h"
|
||||
|
||||
namespace cpr {
|
||||
Payload::Payload(const std::initializer_list<Pair>& pairs) : CurlContainer<Pair>(pairs) {}
|
||||
} // namespace cpr
|
21
vendor/CPR/cpr/proxies.cpp
vendored
21
vendor/CPR/cpr/proxies.cpp
vendored
@ -1,21 +0,0 @@
|
||||
#include "cpr/proxies.h"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
Proxies::Proxies(const std::initializer_list<std::pair<const std::string, std::string>>& hosts)
|
||||
: hosts_{hosts} {}
|
||||
|
||||
bool Proxies::has(const std::string& protocol) const {
|
||||
return hosts_.count(protocol) > 0;
|
||||
}
|
||||
|
||||
const std::string& Proxies::operator[](const std::string& protocol) {
|
||||
return hosts_[protocol];
|
||||
}
|
||||
|
||||
} // namespace cpr
|
46
vendor/CPR/cpr/response.cpp
vendored
46
vendor/CPR/cpr/response.cpp
vendored
@ -1,46 +0,0 @@
|
||||
#include "cpr/response.h"
|
||||
|
||||
namespace cpr {
|
||||
Response::Response(std::shared_ptr<CurlHolder> curl, std::string&& p_text,
|
||||
std::string&& p_header_string, Cookies&& p_cookies = Cookies{},
|
||||
Error&& p_error = Error{})
|
||||
: curl_(std::move(curl)), text(std::move(p_text)), cookies(std::move(p_cookies)),
|
||||
error(std::move(p_error)) {
|
||||
header = cpr::util::parseHeader(p_header_string, &status_line, &reason);
|
||||
assert(curl_);
|
||||
assert(curl_->handle);
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_RESPONSE_CODE, &status_code);
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_TOTAL_TIME, &elapsed);
|
||||
char* url_string{nullptr};
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_EFFECTIVE_URL, &url_string);
|
||||
url = Url(url_string);
|
||||
#if LIBCURL_VERSION_NUM >= 0x073700
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_DOWNLOAD_T, &downloaded_bytes);
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_UPLOAD_T, &uploaded_bytes);
|
||||
#else
|
||||
double downloaded_bytes_double, uploaded_bytes_double;
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_DOWNLOAD, &downloaded_bytes_double);
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_UPLOAD, &uploaded_bytes_double);
|
||||
downloaded_bytes = downloaded_bytes_double;
|
||||
uploaded_bytes = uploaded_bytes_double;
|
||||
#endif
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_REDIRECT_COUNT, &redirect_count);
|
||||
}
|
||||
|
||||
std::vector<std::string> Response::GetCertInfo() {
|
||||
assert(curl_);
|
||||
assert(curl_->handle);
|
||||
curl_certinfo* ci{nullptr};
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_CERTINFO, &ci);
|
||||
|
||||
std::vector<std::string> info;
|
||||
info.resize(ci->num_of_certs);
|
||||
for (size_t i = 0; i < ci->num_of_certs; i++) {
|
||||
// No way around here.
|
||||
// NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
info[i] = std::string{ci->certinfo[i]->data};
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
} // namespace cpr
|
693
vendor/CPR/cpr/session.cpp
vendored
693
vendor/CPR/cpr/session.cpp
vendored
@ -1,693 +0,0 @@
|
||||
#include "cpr/session.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "cpr/curlholder.h"
|
||||
#include "cpr/util.h"
|
||||
|
||||
|
||||
namespace cpr {
|
||||
|
||||
// Ignored here since libcurl reqires a long:
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
constexpr long ON = 1L;
|
||||
// Ignored here since libcurl reqires a long:
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
constexpr long OFF = 0L;
|
||||
|
||||
class Session::Impl {
|
||||
public:
|
||||
Impl();
|
||||
|
||||
void SetUrl(const Url& url);
|
||||
void SetParameters(const Parameters& parameters);
|
||||
void SetParameters(Parameters&& parameters);
|
||||
void SetHeader(const Header& header);
|
||||
void SetTimeout(const Timeout& timeout);
|
||||
void SetConnectTimeout(const ConnectTimeout& timeout);
|
||||
void SetAuth(const Authentication& auth);
|
||||
// Only supported with libcurl >= 7.61.0.
|
||||
// As an alternative use SetHeader and add the token manually.
|
||||
#if LIBCURL_VERSION_NUM >= 0x073D00
|
||||
void SetBearer(const Bearer& token);
|
||||
#endif
|
||||
void SetDigest(const Digest& auth);
|
||||
void SetUserAgent(const UserAgent& ua);
|
||||
void SetPayload(Payload&& payload);
|
||||
void SetPayload(const Payload& payload);
|
||||
void SetProxies(Proxies&& proxies);
|
||||
void SetProxies(const Proxies& proxies);
|
||||
void SetMultipart(Multipart&& multipart);
|
||||
void SetMultipart(const Multipart& multipart);
|
||||
void SetNTLM(const NTLM& auth);
|
||||
void SetRedirect(const bool& redirect);
|
||||
void SetMaxRedirects(const MaxRedirects& max_redirects);
|
||||
void SetCookies(const Cookies& cookies);
|
||||
void SetBody(Body&& body);
|
||||
void SetBody(const Body& body);
|
||||
void SetReadCallback(const ReadCallback& read);
|
||||
void SetHeaderCallback(const HeaderCallback& header);
|
||||
void SetWriteCallback(const WriteCallback& write);
|
||||
void SetProgressCallback(const ProgressCallback& progress);
|
||||
void SetDebugCallback(const DebugCallback& debug);
|
||||
void SetLowSpeed(const LowSpeed& low_speed);
|
||||
void SetVerifySsl(const VerifySsl& verify);
|
||||
void SetLimitRate(const LimitRate& limit_rate);
|
||||
void SetUnixSocket(const UnixSocket& unix_socket);
|
||||
void SetVerbose(const Verbose& verbose);
|
||||
void SetSslOptions(const SslOptions& options);
|
||||
|
||||
Response Delete();
|
||||
Response Download(const WriteCallback& write);
|
||||
Response Download(std::ofstream& file);
|
||||
Response Get();
|
||||
Response Head();
|
||||
Response Options();
|
||||
Response Patch();
|
||||
Response Post();
|
||||
Response Put();
|
||||
|
||||
private:
|
||||
bool hasBodyOrPayload_{false};
|
||||
|
||||
std::shared_ptr<CurlHolder> curl_;
|
||||
Url url_;
|
||||
Parameters parameters_;
|
||||
Proxies proxies_;
|
||||
|
||||
ReadCallback readcb_;
|
||||
HeaderCallback headercb_;
|
||||
WriteCallback writecb_;
|
||||
ProgressCallback progresscb_;
|
||||
DebugCallback debugcb_;
|
||||
|
||||
Response makeDownloadRequest();
|
||||
Response makeRequest();
|
||||
static void freeHolder(CurlHolder* holder);
|
||||
};
|
||||
|
||||
Session::Impl::Impl() : curl_(new CurlHolder()) {
|
||||
// Set up some sensible defaults
|
||||
curl_version_info_data* version_info = curl_version_info(CURLVERSION_NOW);
|
||||
std::string version = "curl/" + std::string{version_info->version};
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_USERAGENT, version.c_str());
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOPROGRESS, 1L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_MAXREDIRS, 50L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_ERRORBUFFER, curl_->error.data());
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_COOKIEFILE, "");
|
||||
#ifdef CPR_CURL_NOSIGNAL
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOSIGNAL, 1L);
|
||||
#endif
|
||||
|
||||
#if LIBCURL_VERSION_MAJOR >= 7
|
||||
#if LIBCURL_VERSION_MINOR >= 25
|
||||
#if LIBCURL_VERSION_PATCH >= 0
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_TCP_KEEPALIVE, 1L);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Session::Impl::SetUrl(const Url& url) {
|
||||
url_ = url;
|
||||
}
|
||||
|
||||
void Session::Impl::SetParameters(const Parameters& parameters) {
|
||||
parameters_ = parameters;
|
||||
}
|
||||
|
||||
void Session::Impl::SetParameters(Parameters&& parameters) {
|
||||
parameters_ = std::move(parameters);
|
||||
}
|
||||
|
||||
void Session::Impl::SetHeader(const Header& header) {
|
||||
curl_slist* chunk = nullptr;
|
||||
for (const std::pair<const std::string, std::string>& item : header) {
|
||||
std::string header_string = item.first;
|
||||
if (item.second.empty()) {
|
||||
header_string += ";";
|
||||
} else {
|
||||
header_string += ": " + item.second;
|
||||
}
|
||||
|
||||
curl_slist* temp = curl_slist_append(chunk, header_string.c_str());
|
||||
if (temp) {
|
||||
chunk = temp;
|
||||
}
|
||||
}
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPHEADER, chunk);
|
||||
|
||||
curl_slist_free_all(curl_->chunk);
|
||||
curl_->chunk = chunk;
|
||||
}
|
||||
|
||||
void Session::Impl::SetTimeout(const Timeout& timeout) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_TIMEOUT_MS, timeout.Milliseconds());
|
||||
}
|
||||
|
||||
void Session::Impl::SetConnectTimeout(const ConnectTimeout& timeout) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CONNECTTIMEOUT_MS, timeout.Milliseconds());
|
||||
}
|
||||
|
||||
void Session::Impl::SetVerbose(const Verbose& verbose) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_VERBOSE, verbose.verbose ? ON : OFF);
|
||||
}
|
||||
|
||||
void Session::Impl::SetAuth(const Authentication& auth) {
|
||||
// Ignore here since this has been defined by libcurl.
|
||||
// NOLINTNEXTLINE(hicpp-signed-bitwise)
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_USERPWD, auth.GetAuthString());
|
||||
}
|
||||
|
||||
// Only supported with libcurl >= 7.61.0.
|
||||
// As an alternative use SetHeader and add the token manually.
|
||||
#if LIBCURL_VERSION_NUM >= 0x073D00
|
||||
void Session::Impl::SetBearer(const Bearer& token) {
|
||||
// Ignore here since this has been defined by libcurl.
|
||||
// NOLINTNEXTLINE(hicpp-signed-bitwise)
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPAUTH, CURLAUTH_BEARER);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_XOAUTH2_BEARER, token.GetToken());
|
||||
}
|
||||
#endif
|
||||
|
||||
void Session::Impl::SetDigest(const Digest& auth) {
|
||||
// Ignore here since this has been defined by libcurl.
|
||||
// NOLINTNEXTLINE(hicpp-signed-bitwise)
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_USERPWD, auth.GetAuthString());
|
||||
}
|
||||
|
||||
void Session::Impl::SetUserAgent(const UserAgent& ua) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_USERAGENT, ua.c_str());
|
||||
}
|
||||
|
||||
void Session::Impl::SetPayload(Payload&& payload) {
|
||||
hasBodyOrPayload_ = true;
|
||||
const std::string content = payload.GetContent(*curl_);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE,
|
||||
static_cast<curl_off_t>(content.length()));
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, content.c_str());
|
||||
}
|
||||
|
||||
void Session::Impl::SetPayload(const Payload& payload) {
|
||||
hasBodyOrPayload_ = true;
|
||||
const std::string content = payload.GetContent(*curl_);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE,
|
||||
static_cast<curl_off_t>(content.length()));
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, content.c_str());
|
||||
}
|
||||
|
||||
void Session::Impl::SetProxies(const Proxies& proxies) {
|
||||
proxies_ = proxies;
|
||||
}
|
||||
|
||||
void Session::Impl::SetProxies(Proxies&& proxies) {
|
||||
proxies_ = std::move(proxies);
|
||||
}
|
||||
|
||||
void Session::Impl::SetMultipart(Multipart&& multipart) {
|
||||
curl_httppost* formpost = nullptr;
|
||||
curl_httppost* lastptr = nullptr;
|
||||
|
||||
for (const Part& part : multipart.parts) {
|
||||
std::vector<curl_forms> formdata;
|
||||
if (part.is_buffer) {
|
||||
// Do not use formdata, to prevent having to use reinterpreter_cast:
|
||||
curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, part.name.c_str(), CURLFORM_BUFFER,
|
||||
part.value.c_str(), CURLFORM_BUFFERPTR, part.data, CURLFORM_BUFFERLENGTH,
|
||||
part.datalen, CURLFORM_END);
|
||||
} else {
|
||||
formdata.push_back({CURLFORM_COPYNAME, part.name.c_str()});
|
||||
if (part.is_file) {
|
||||
formdata.push_back({CURLFORM_FILE, part.value.c_str()});
|
||||
} else {
|
||||
formdata.push_back({CURLFORM_COPYCONTENTS, part.value.c_str()});
|
||||
}
|
||||
}
|
||||
if (!part.content_type.empty()) {
|
||||
formdata.push_back({CURLFORM_CONTENTTYPE, part.content_type.c_str()});
|
||||
}
|
||||
|
||||
formdata.push_back({CURLFORM_END, nullptr});
|
||||
curl_formadd(&formpost, &lastptr, CURLFORM_ARRAY, formdata.data(), CURLFORM_END);
|
||||
}
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPPOST, formpost);
|
||||
hasBodyOrPayload_ = true;
|
||||
|
||||
curl_formfree(curl_->formpost);
|
||||
curl_->formpost = formpost;
|
||||
}
|
||||
|
||||
void Session::Impl::SetMultipart(const Multipart& multipart) {
|
||||
curl_httppost* formpost = nullptr;
|
||||
curl_httppost* lastptr = nullptr;
|
||||
|
||||
for (const Part& part : multipart.parts) {
|
||||
std::vector<curl_forms> formdata;
|
||||
if (part.is_buffer) {
|
||||
// Do not use formdata, to prevent having to use reinterpreter_cast:
|
||||
curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, part.name.c_str(), CURLFORM_BUFFER,
|
||||
part.value.c_str(), CURLFORM_BUFFERPTR, part.data, CURLFORM_BUFFERLENGTH,
|
||||
part.datalen, CURLFORM_END);
|
||||
} else {
|
||||
formdata.push_back({CURLFORM_COPYNAME, part.name.c_str()});
|
||||
if (part.is_file) {
|
||||
formdata.push_back({CURLFORM_FILE, part.value.c_str()});
|
||||
} else {
|
||||
formdata.push_back({CURLFORM_COPYCONTENTS, part.value.c_str()});
|
||||
}
|
||||
}
|
||||
if (!part.content_type.empty()) {
|
||||
formdata.push_back({CURLFORM_CONTENTTYPE, part.content_type.c_str()});
|
||||
}
|
||||
|
||||
formdata.push_back({CURLFORM_END, nullptr});
|
||||
curl_formadd(&formpost, &lastptr, CURLFORM_ARRAY, formdata.data(), CURLFORM_END);
|
||||
}
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPPOST, formpost);
|
||||
hasBodyOrPayload_ = true;
|
||||
|
||||
curl_formfree(curl_->formpost);
|
||||
curl_->formpost = formpost;
|
||||
}
|
||||
|
||||
void Session::Impl::SetLimitRate(const LimitRate& limit_rate) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_MAX_RECV_SPEED_LARGE, limit_rate.downrate);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_MAX_SEND_SPEED_LARGE, limit_rate.uprate);
|
||||
}
|
||||
|
||||
void Session::Impl::SetNTLM(const NTLM& auth) {
|
||||
// Ignore here since this has been defined by libcurl.
|
||||
// NOLINTNEXTLINE(hicpp-signed-bitwise)
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_USERPWD, auth.GetAuthString());
|
||||
}
|
||||
|
||||
void Session::Impl::SetRedirect(const bool& redirect) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_FOLLOWLOCATION, std::int32_t(redirect));
|
||||
}
|
||||
|
||||
void Session::Impl::SetMaxRedirects(const MaxRedirects& max_redirects) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_MAXREDIRS, max_redirects.number_of_redirects);
|
||||
}
|
||||
|
||||
void Session::Impl::SetCookies(const Cookies& cookies) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_COOKIELIST, "ALL");
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_COOKIE, cookies.GetEncoded(*curl_).c_str());
|
||||
}
|
||||
|
||||
void Session::Impl::SetBody(Body&& body) {
|
||||
hasBodyOrPayload_ = true;
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE,
|
||||
static_cast<curl_off_t>(body.str().length()));
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, body.c_str());
|
||||
}
|
||||
|
||||
void Session::Impl::SetBody(const Body& body) {
|
||||
hasBodyOrPayload_ = true;
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE,
|
||||
static_cast<curl_off_t>(body.str().length()));
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDS, body.c_str());
|
||||
}
|
||||
|
||||
void Session::Impl::SetReadCallback(const ReadCallback& read) {
|
||||
readcb_ = read;
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_INFILESIZE_LARGE, read.size);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, read.size);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_READFUNCTION, cpr::util::readUserFunction);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_READDATA, &readcb_);
|
||||
if (read.size == -1) {
|
||||
SetHeader({{"Transfer-Encoding", "chunked"}});
|
||||
}
|
||||
}
|
||||
|
||||
void Session::Impl::SetHeaderCallback(const HeaderCallback& header) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::headerUserFunction);
|
||||
headercb_ = header;
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &headercb_);
|
||||
}
|
||||
|
||||
void Session::Impl::SetWriteCallback(const WriteCallback& write) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_WRITEFUNCTION, cpr::util::writeUserFunction);
|
||||
writecb_ = write;
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_WRITEDATA, &writecb_);
|
||||
}
|
||||
|
||||
void Session::Impl::SetProgressCallback(const ProgressCallback& progress) {
|
||||
progresscb_ = progress;
|
||||
#if LIBCURL_VERSION_NUM < 0x072000
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_PROGRESSFUNCTION, cpr::util::progressUserFunction);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_PROGRESSDATA, &progresscb_);
|
||||
#else
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_XFERINFOFUNCTION, cpr::util::progressUserFunction);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_XFERINFODATA, &progresscb_);
|
||||
#endif
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOPROGRESS, 0L);
|
||||
}
|
||||
|
||||
void Session::Impl::SetDebugCallback(const DebugCallback& debug) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_DEBUGFUNCTION, cpr::util::debugUserFunction);
|
||||
debugcb_ = debug;
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_DEBUGDATA, &debugcb_);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_VERBOSE, 1L);
|
||||
}
|
||||
|
||||
void Session::Impl::SetLowSpeed(const LowSpeed& low_speed) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_LOW_SPEED_LIMIT, low_speed.limit);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_LOW_SPEED_TIME, low_speed.time);
|
||||
}
|
||||
|
||||
void Session::Impl::SetVerifySsl(const VerifySsl& verify) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYPEER, verify ? ON : OFF);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYHOST, verify ? 2L : 0L);
|
||||
}
|
||||
|
||||
void Session::Impl::SetUnixSocket(const UnixSocket& unix_socket) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_UNIX_SOCKET_PATH, unix_socket.GetUnixSocketString());
|
||||
}
|
||||
|
||||
void Session::Impl::SetSslOptions(const SslOptions& options) {
|
||||
if (!options.cert_file.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSLCERT, options.cert_file.c_str());
|
||||
if (!options.cert_type.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSLCERTTYPE, options.cert_type.c_str());
|
||||
}
|
||||
}
|
||||
if (!options.key_file.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSLKEY, options.key_file.c_str());
|
||||
if (!options.key_type.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSLKEYTYPE, options.key_type.c_str());
|
||||
}
|
||||
if (!options.key_pass.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_KEYPASSWD, options.key_pass.c_str());
|
||||
}
|
||||
}
|
||||
#if SUPPORT_ALPN
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_ENABLE_ALPN, options.enable_alpn ? ON : OFF);
|
||||
#endif
|
||||
#if SUPPORT_NPN
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_ENABLE_NPN, options.enable_npn ? ON : OFF);
|
||||
#endif
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYPEER, options.verify_peer ? ON : OFF);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYHOST, options.verify_host ? 2L : 0L);
|
||||
#if LIBCURL_VERSION_NUM >= 0x072900
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYSTATUS, options.verify_status ? ON : OFF);
|
||||
#endif
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSLVERSION,
|
||||
// Ignore here since this has been defined by libcurl.
|
||||
// NOLINTNEXTLINE(hicpp-signed-bitwise)
|
||||
options.ssl_version
|
||||
#if SUPPORT_MAX_TLS_VERSION
|
||||
| options.max_version
|
||||
#endif
|
||||
);
|
||||
if (!options.ca_info.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CAINFO, options.ca_info.c_str());
|
||||
}
|
||||
if (!options.ca_path.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CAPATH, options.ca_path.c_str());
|
||||
}
|
||||
if (!options.crl_file.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CRLFILE, options.crl_file.c_str());
|
||||
}
|
||||
if (!options.ciphers.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_CIPHER_LIST, options.ciphers.c_str());
|
||||
}
|
||||
#if SUPPORT_TLSv13_CIPHERS
|
||||
if (!options.tls13_ciphers.empty()) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_TLS13_CIPHERS, options.ciphers.c_str());
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_SESSIONID_CACHE
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_SSL_SESSIONID_CACHE,
|
||||
options.session_id_cache ? ON : OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
Response Session::Impl::Delete() {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPGET, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
|
||||
return makeRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::Download(const WriteCallback& write) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
|
||||
SetWriteCallback(write);
|
||||
|
||||
return makeDownloadRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::Download(std::ofstream& file) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_WRITEFUNCTION, cpr::util::writeFileFunction);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_WRITEDATA, &file);
|
||||
|
||||
return makeDownloadRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::Get() {
|
||||
// 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.
|
||||
if (hasBodyOrPayload_) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
} else {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HTTPGET, 1L);
|
||||
}
|
||||
|
||||
return makeRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::Head() {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 1L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr);
|
||||
|
||||
return makeRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::Options() {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
||||
|
||||
return makeRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::Patch() {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||
|
||||
return makeRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::Post() {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
|
||||
// In case there is no body or payload set it to an empty post:
|
||||
if (hasBodyOrPayload_) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr);
|
||||
} else {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDS, readcb_.callback ? nullptr : "");
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
}
|
||||
|
||||
return makeRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::Put() {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
|
||||
return makeRequest();
|
||||
}
|
||||
|
||||
Response Session::Impl::makeDownloadRequest() {
|
||||
assert(curl_->handle);
|
||||
const std::string parametersContent = parameters_.GetContent(*curl_);
|
||||
if (!parametersContent.empty()) {
|
||||
Url new_url{url_ + "?" + parametersContent};
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_URL, new_url.c_str());
|
||||
} else {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_URL, url_.c_str());
|
||||
}
|
||||
|
||||
std::string protocol = url_.str().substr(0, url_.str().find(':'));
|
||||
if (proxies_.has(protocol)) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, proxies_[protocol].c_str());
|
||||
} else {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, "");
|
||||
}
|
||||
|
||||
curl_->error[0] = '\0';
|
||||
|
||||
std::string header_string;
|
||||
if (headercb_.callback) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::headerUserFunction);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &headercb_);
|
||||
} else {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::writeFunction);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &header_string);
|
||||
}
|
||||
|
||||
CURLcode curl_error = curl_easy_perform(curl_->handle);
|
||||
|
||||
curl_slist* raw_cookies{nullptr};
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_COOKIELIST, &raw_cookies);
|
||||
Cookies cookies = util::parseCookies(raw_cookies);
|
||||
curl_slist_free_all(raw_cookies);
|
||||
std::string errorMsg = curl_->error.data();
|
||||
|
||||
return Response(curl_, "", std::move(header_string), std::move(cookies),
|
||||
Error(curl_error, std::move(errorMsg)));
|
||||
}
|
||||
|
||||
Response Session::Impl::makeRequest() {
|
||||
assert(curl_->handle);
|
||||
const std::string parametersContent = parameters_.GetContent(*curl_);
|
||||
if (!parametersContent.empty()) {
|
||||
Url new_url{url_ + "?" + parametersContent};
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_URL, new_url.c_str());
|
||||
} else {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_URL, url_.c_str());
|
||||
}
|
||||
|
||||
std::string protocol = url_.str().substr(0, url_.str().find(':'));
|
||||
if (proxies_.has(protocol)) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, proxies_[protocol].c_str());
|
||||
} else {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_PROXY, nullptr);
|
||||
}
|
||||
|
||||
#if LIBCURL_VERSION_MAJOR >= 7
|
||||
#if LIBCURL_VERSION_MINOR >= 21
|
||||
/* enable all supported built-in compressions */
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_ACCEPT_ENCODING, "");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
curl_->error[0] = '\0';
|
||||
|
||||
std::string response_string;
|
||||
std::string header_string;
|
||||
if (!this->writecb_.callback) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_WRITEFUNCTION, cpr::util::writeFunction);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_WRITEDATA, &response_string);
|
||||
}
|
||||
if (!this->headercb_.callback) {
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::writeFunction);
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &header_string);
|
||||
}
|
||||
|
||||
// Enable so we are able to retrive certificate information:
|
||||
curl_easy_setopt(curl_->handle, CURLOPT_CERTINFO, 1L);
|
||||
|
||||
CURLcode curl_error = curl_easy_perform(curl_->handle);
|
||||
|
||||
curl_slist* raw_cookies{nullptr};
|
||||
curl_easy_getinfo(curl_->handle, CURLINFO_COOKIELIST, &raw_cookies);
|
||||
Cookies cookies = util::parseCookies(raw_cookies);
|
||||
curl_slist_free_all(raw_cookies);
|
||||
|
||||
// Reset the has no body property:
|
||||
hasBodyOrPayload_ = false;
|
||||
|
||||
std::string errorMsg = curl_->error.data();
|
||||
return Response(curl_, std::move(response_string), std::move(header_string), std::move(cookies),
|
||||
Error(curl_error, std::move(errorMsg)));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
Session::Session() : pimpl_(new Impl()) {}
|
||||
Session::~Session() = default;
|
||||
void Session::SetReadCallback(const ReadCallback& read) { pimpl_->SetReadCallback(read); }
|
||||
void Session::SetHeaderCallback(const HeaderCallback& header) { pimpl_->SetHeaderCallback(header); }
|
||||
void Session::SetWriteCallback(const WriteCallback& write) { pimpl_->SetWriteCallback(write); }
|
||||
void Session::SetProgressCallback(const ProgressCallback& progress) { pimpl_->SetProgressCallback(progress); }
|
||||
void Session::SetUrl(const Url& url) { pimpl_->SetUrl(url); }
|
||||
void Session::SetParameters(const Parameters& parameters) { pimpl_->SetParameters(parameters); }
|
||||
void Session::SetParameters(Parameters&& parameters) { pimpl_->SetParameters(std::move(parameters)); }
|
||||
void Session::SetHeader(const Header& header) { pimpl_->SetHeader(header); }
|
||||
void Session::SetTimeout(const Timeout& timeout) { pimpl_->SetTimeout(timeout); }
|
||||
void Session::SetConnectTimeout(const ConnectTimeout& timeout) { pimpl_->SetConnectTimeout(timeout); }
|
||||
void Session::SetAuth(const Authentication& auth) { pimpl_->SetAuth(auth); }
|
||||
void Session::SetDigest(const Digest& auth) { pimpl_->SetDigest(auth); }
|
||||
void Session::SetUserAgent(const UserAgent& ua) { pimpl_->SetUserAgent(ua); }
|
||||
void Session::SetPayload(const Payload& payload) { pimpl_->SetPayload(payload); }
|
||||
void Session::SetPayload(Payload&& payload) { pimpl_->SetPayload(std::move(payload)); }
|
||||
void Session::SetProxies(const Proxies& proxies) { pimpl_->SetProxies(proxies); }
|
||||
void Session::SetProxies(Proxies&& proxies) { pimpl_->SetProxies(std::move(proxies)); }
|
||||
void Session::SetMultipart(const Multipart& multipart) { pimpl_->SetMultipart(multipart); }
|
||||
void Session::SetMultipart(Multipart&& multipart) { pimpl_->SetMultipart(std::move(multipart)); }
|
||||
void Session::SetNTLM(const NTLM& auth) { pimpl_->SetNTLM(auth); }
|
||||
void Session::SetRedirect(const bool& redirect) { pimpl_->SetRedirect(redirect); }
|
||||
void Session::SetMaxRedirects(const MaxRedirects& max_redirects) { pimpl_->SetMaxRedirects(max_redirects); }
|
||||
void Session::SetCookies(const Cookies& cookies) { pimpl_->SetCookies(cookies); }
|
||||
void Session::SetBody(const Body& body) { pimpl_->SetBody(body); }
|
||||
void Session::SetBody(Body&& body) { pimpl_->SetBody(std::move(body)); }
|
||||
void Session::SetLowSpeed(const LowSpeed& low_speed) { pimpl_->SetLowSpeed(low_speed); }
|
||||
void Session::SetVerifySsl(const VerifySsl& verify) { pimpl_->SetVerifySsl(verify); }
|
||||
void Session::SetUnixSocket(const UnixSocket& unix_socket) { pimpl_->SetUnixSocket(unix_socket); }
|
||||
void Session::SetSslOptions(const SslOptions& options) { pimpl_->SetSslOptions(options); }
|
||||
void Session::SetVerbose(const Verbose& verbose) { pimpl_->SetVerbose(verbose); }
|
||||
void Session::SetOption(const ReadCallback& read) { pimpl_->SetReadCallback(read); }
|
||||
void Session::SetOption(const HeaderCallback& header) { pimpl_->SetHeaderCallback(header); }
|
||||
void Session::SetOption(const WriteCallback& write) { pimpl_->SetWriteCallback(write); }
|
||||
void Session::SetOption(const ProgressCallback& progress) { pimpl_->SetProgressCallback(progress); }
|
||||
void Session::SetOption(const DebugCallback& debug) { pimpl_->SetDebugCallback(debug); }
|
||||
void Session::SetOption(const Url& url) { pimpl_->SetUrl(url); }
|
||||
void Session::SetOption(const Parameters& parameters) { pimpl_->SetParameters(parameters); }
|
||||
void Session::SetOption(Parameters&& parameters) { pimpl_->SetParameters(std::move(parameters)); }
|
||||
void Session::SetOption(const Header& header) { pimpl_->SetHeader(header); }
|
||||
void Session::SetOption(const Timeout& timeout) { pimpl_->SetTimeout(timeout); }
|
||||
void Session::SetOption(const ConnectTimeout& timeout) { pimpl_->SetConnectTimeout(timeout); }
|
||||
void Session::SetOption(const Authentication& auth) { pimpl_->SetAuth(auth); }
|
||||
// Only supported with libcurl >= 7.61.0.
|
||||
// As an alternative use SetHeader and add the token manually.
|
||||
#if LIBCURL_VERSION_NUM >= 0x073D00
|
||||
void Session::SetOption(const Bearer& auth) { pimpl_->SetBearer(auth); }
|
||||
#endif
|
||||
void Session::SetOption(const Digest& auth) { pimpl_->SetDigest(auth); }
|
||||
void Session::SetOption(const UserAgent& ua) { pimpl_->SetUserAgent(ua); }
|
||||
void Session::SetOption(const Payload& payload) { pimpl_->SetPayload(payload); }
|
||||
void Session::SetOption(Payload&& payload) { pimpl_->SetPayload(std::move(payload)); }
|
||||
void Session::SetOption(const Proxies& proxies) { pimpl_->SetProxies(proxies); }
|
||||
void Session::SetOption(Proxies&& proxies) { pimpl_->SetProxies(std::move(proxies)); }
|
||||
void Session::SetOption(const Multipart& multipart) { pimpl_->SetMultipart(multipart); }
|
||||
void Session::SetOption(Multipart&& multipart) { pimpl_->SetMultipart(std::move(multipart)); }
|
||||
void Session::SetOption(const NTLM& auth) { pimpl_->SetNTLM(auth); }
|
||||
void Session::SetOption(const bool& redirect) { pimpl_->SetRedirect(redirect); }
|
||||
void Session::SetOption(const MaxRedirects& max_redirects) { pimpl_->SetMaxRedirects(max_redirects); }
|
||||
void Session::SetOption(const Cookies& cookies) { pimpl_->SetCookies(cookies); }
|
||||
void Session::SetOption(const Body& body) { pimpl_->SetBody(body); }
|
||||
void Session::SetOption(Body&& body) { pimpl_->SetBody(std::move(body)); }
|
||||
void Session::SetOption(const LowSpeed& low_speed) { pimpl_->SetLowSpeed(low_speed); }
|
||||
void Session::SetOption(const VerifySsl& verify) { pimpl_->SetVerifySsl(verify); }
|
||||
void Session::SetOption(const Verbose& verbose) { pimpl_->SetVerbose(verbose); }
|
||||
void Session::SetOption(const UnixSocket& unix_socket) { pimpl_->SetUnixSocket(unix_socket); }
|
||||
void Session::SetOption(const SslOptions& options) { pimpl_->SetSslOptions(options); }
|
||||
|
||||
Response Session::Delete() { return pimpl_->Delete(); }
|
||||
Response Session::Download(const WriteCallback& write) { return pimpl_->Download(write); }
|
||||
Response Session::Download(std::ofstream& file) { return pimpl_->Download(file); }
|
||||
Response Session::Get() { return pimpl_->Get(); }
|
||||
Response Session::Head() { return pimpl_->Head(); }
|
||||
Response Session::Options() { return pimpl_->Options(); }
|
||||
Response Session::Patch() { return pimpl_->Patch(); }
|
||||
Response Session::Post() { return pimpl_->Post(); }
|
||||
Response Session::Put() { return pimpl_->Put(); }
|
||||
// clang-format on
|
||||
} // namespace cpr
|
34
vendor/CPR/cpr/timeout.cpp
vendored
34
vendor/CPR/cpr/timeout.cpp
vendored
@ -1,34 +0,0 @@
|
||||
#include "cpr/timeout.h"
|
||||
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
// No way around since curl uses a long here.
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
long Timeout::Milliseconds() const {
|
||||
static_assert(std::is_same<std::chrono::milliseconds, decltype(ms)>::value,
|
||||
"Following casting expects milliseconds.");
|
||||
|
||||
// No way around since curl uses a long here.
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
if (ms.count() > std::numeric_limits<long>::max()) {
|
||||
throw std::overflow_error(
|
||||
"cpr::Timeout: timeout value overflow: " + std::to_string(ms.count()) + " ms.");
|
||||
}
|
||||
// No way around since curl uses a long here.
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
if (ms.count() < std::numeric_limits<long>::min()) {
|
||||
throw std::underflow_error(
|
||||
"cpr::Timeout: timeout value underflow: " + std::to_string(ms.count()) + " ms.");
|
||||
}
|
||||
|
||||
// No way around since curl uses a long here.
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
return static_cast<long>(ms.count());
|
||||
}
|
||||
|
||||
} // namespace cpr
|
8
vendor/CPR/cpr/unix_socket.cpp
vendored
8
vendor/CPR/cpr/unix_socket.cpp
vendored
@ -1,8 +0,0 @@
|
||||
|
||||
#include "cpr/unix_socket.h"
|
||||
|
||||
namespace cpr {
|
||||
const char* UnixSocket::GetUnixSocketString() const noexcept {
|
||||
return unix_socket_.data();
|
||||
}
|
||||
} // namespace cpr
|
164
vendor/CPR/cpr/util.cpp
vendored
164
vendor/CPR/cpr/util.cpp
vendored
@ -1,164 +0,0 @@
|
||||
#include "cpr/util.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace cpr {
|
||||
namespace util {
|
||||
|
||||
Cookies parseCookies(curl_slist* raw_cookies) {
|
||||
Cookies cookies;
|
||||
for (curl_slist* nc = raw_cookies; nc; nc = nc->next) {
|
||||
std::vector<std::string> tokens = cpr::util::split(nc->data, '\t');
|
||||
std::string value = tokens.back();
|
||||
tokens.pop_back();
|
||||
cookies[tokens.back()] = value;
|
||||
}
|
||||
return cookies;
|
||||
}
|
||||
|
||||
Header parseHeader(const std::string& headers, std::string* status_line, std::string* reason) {
|
||||
Header header;
|
||||
std::vector<std::string> lines;
|
||||
std::istringstream stream(headers);
|
||||
{
|
||||
std::string line;
|
||||
while (std::getline(stream, line, '\n')) {
|
||||
lines.push_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
for (std::string& line : lines) {
|
||||
// NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers)
|
||||
if (line.substr(0, 5) == "HTTP/") {
|
||||
// set the status_line if it was given
|
||||
if ((status_line != nullptr) || (reason != nullptr)) {
|
||||
line.resize(std::min<size_t>(line.size(), line.find_last_not_of("\t\n\r ") + 1));
|
||||
if (status_line != nullptr) {
|
||||
*status_line = line;
|
||||
}
|
||||
|
||||
// set the reason if it was given
|
||||
if (reason != nullptr) {
|
||||
size_t pos1 = line.find_first_of("\t ");
|
||||
size_t pos2 = std::string::npos;
|
||||
if (pos1 != std::string::npos) {
|
||||
pos2 = line.find_first_of("\t ", pos1 + 1);
|
||||
}
|
||||
if (pos2 != std::string::npos) {
|
||||
line.erase(0, pos2 + 1);
|
||||
*reason = line;
|
||||
}
|
||||
}
|
||||
}
|
||||
header.clear();
|
||||
}
|
||||
|
||||
if (line.length() > 0) {
|
||||
size_t found = line.find(':');
|
||||
if (found != std::string::npos) {
|
||||
std::string value = line.substr(found + 1);
|
||||
value.erase(0, value.find_first_not_of("\t "));
|
||||
value.resize(std::min<size_t>(value.size(), value.find_last_not_of("\t\n\r ") + 1));
|
||||
header[line.substr(0, found)] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
std::vector<std::string> split(const std::string& to_split, char delimiter) {
|
||||
std::vector<std::string> tokens;
|
||||
|
||||
std::stringstream stream(to_split);
|
||||
std::string item;
|
||||
while (std::getline(stream, item, delimiter)) {
|
||||
tokens.push_back(item);
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
size_t readUserFunction(char* ptr, size_t size, size_t nitems, const ReadCallback* read) {
|
||||
size *= nitems;
|
||||
return read->callback(ptr, size) ? size : CURL_READFUNC_ABORT;
|
||||
}
|
||||
|
||||
size_t headerUserFunction(char* ptr, size_t size, size_t nmemb, const HeaderCallback* header) {
|
||||
size *= nmemb;
|
||||
return header->callback({ptr, size}) ? size : 0;
|
||||
}
|
||||
|
||||
size_t writeFunction(char* ptr, size_t size, size_t nmemb, std::string* data) {
|
||||
size *= nmemb;
|
||||
data->append(ptr, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t writeFileFunction(char* ptr, size_t size, size_t nmemb, std::ofstream* file) {
|
||||
size *= nmemb;
|
||||
file->write(ptr, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t writeUserFunction(char* ptr, size_t size, size_t nmemb, const WriteCallback* write) {
|
||||
size *= nmemb;
|
||||
return write->callback({ptr, size}) ? size : 0;
|
||||
}
|
||||
|
||||
#if LIBCURL_VERSION_NUM < 0x072000
|
||||
int progressUserFunction(const ProgressCallback* progress, double dltotal, double dlnow,
|
||||
double ultotal, double ulnow) {
|
||||
#else
|
||||
int progressUserFunction(const ProgressCallback* progress, curl_off_t dltotal, curl_off_t dlnow,
|
||||
curl_off_t ultotal, curl_off_t ulnow) {
|
||||
#endif
|
||||
return progress->callback(dltotal, dlnow, ultotal, ulnow) ? 0 : 1;
|
||||
}
|
||||
|
||||
int debugUserFunction(CURL* /*handle*/, curl_infotype type, char* data, size_t size,
|
||||
const DebugCallback* debug) {
|
||||
debug->callback(DebugCallback::InfoType(type), std::string(data, size));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a temporary CurlHolder object and uses it to escape the given string.
|
||||
* If you plan to use this methode on a regular basis think about creating a CurlHolder
|
||||
* object and calling urlEncode(std::string) on it.
|
||||
*
|
||||
* Example:
|
||||
* CurlHolder holder;
|
||||
* std::string input = "Hello World!";
|
||||
* std::string result = holder.urlEncode(input);
|
||||
**/
|
||||
std::string urlEncode(const std::string& s) {
|
||||
CurlHolder holder; // Create a temporary new holder for URL encoding
|
||||
return holder.urlEncode(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a temporary CurlHolder object and uses it to unescape the given string.
|
||||
* If you plan to use this methode on a regular basis think about creating a CurlHolder
|
||||
* object and calling urlDecode(std::string) on it.
|
||||
*
|
||||
* Example:
|
||||
* CurlHolder holder;
|
||||
* std::string input = "Hello%20World%21";
|
||||
* std::string result = holder.urlDecode(input);
|
||||
**/
|
||||
std::string urlDecode(const std::string& s) {
|
||||
CurlHolder holder; // Create a temporary new holder for URL decoding
|
||||
return holder.urlDecode(s);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace cpr
|
229
vendor/CPR/include/cpr/api.h
vendored
229
vendor/CPR/include/cpr/api.h
vendored
@ -1,229 +0,0 @@
|
||||
#ifndef CPR_API_H
|
||||
#define CPR_API_H
|
||||
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "cpr/auth.h"
|
||||
#include "cpr/bearer.h"
|
||||
#include "cpr/cprtypes.h"
|
||||
#include "cpr/digest.h"
|
||||
#include "cpr/multipart.h"
|
||||
#include "cpr/ntlm.h"
|
||||
#include "cpr/payload.h"
|
||||
#include "cpr/response.h"
|
||||
#include "cpr/session.h"
|
||||
#include <utility>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
using AsyncResponse = std::future<Response>;
|
||||
|
||||
namespace priv {
|
||||
|
||||
template <typename T>
|
||||
void set_option(Session& session, T&& t) {
|
||||
session.SetOption(std::forward<T>(t));
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
// Get methods
|
||||
template <typename... Ts>
|
||||
Response Get(Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Get();
|
||||
}
|
||||
|
||||
// Get async methods
|
||||
template <typename... Ts>
|
||||
AsyncResponse GetAsync(Ts... ts) {
|
||||
return std::async(
|
||||
std::launch::async, [](Ts... ts) { return Get(std::move(ts)...); }, std::move(ts)...);
|
||||
}
|
||||
|
||||
// Get callback methods
|
||||
template <typename Then, typename... Ts>
|
||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||
auto GetCallback(Then then, Ts... ts) -> std::future<decltype(then(Get(std::move(ts)...)))> {
|
||||
return std::async(
|
||||
std::launch::async, [](Then then, Ts... ts) { return then(Get(std::move(ts)...)); },
|
||||
std::move(then), std::move(ts)...);
|
||||
}
|
||||
|
||||
// Post methods
|
||||
template <typename... Ts>
|
||||
Response Post(Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Post();
|
||||
}
|
||||
|
||||
// Post async methods
|
||||
template <typename... Ts>
|
||||
AsyncResponse PostAsync(Ts... ts) {
|
||||
return std::async(
|
||||
std::launch::async, [](Ts... ts) { return Post(std::move(ts)...); }, std::move(ts)...);
|
||||
}
|
||||
|
||||
// Post callback methods
|
||||
template <typename Then, typename... Ts>
|
||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||
auto PostCallback(Then then, Ts... ts) -> std::future<decltype(then(Post(std::move(ts)...)))> {
|
||||
return std::async(
|
||||
std::launch::async, [](Then then, Ts... ts) { return then(Post(std::move(ts)...)); },
|
||||
std::move(then), std::move(ts)...);
|
||||
}
|
||||
|
||||
// Put methods
|
||||
template <typename... Ts>
|
||||
Response Put(Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Put();
|
||||
}
|
||||
|
||||
// Put async methods
|
||||
template <typename... Ts>
|
||||
AsyncResponse PutAsync(Ts... ts) {
|
||||
return std::async(
|
||||
std::launch::async, [](Ts... ts) { return Put(std::move(ts)...); }, std::move(ts)...);
|
||||
}
|
||||
|
||||
// Put callback methods
|
||||
template <typename Then, typename... Ts>
|
||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||
auto PutCallback(Then then, Ts... ts) -> std::future<decltype(then(Put(std::move(ts)...)))> {
|
||||
return std::async(
|
||||
std::launch::async, [](Then then, Ts... ts) { return then(Put(std::move(ts)...)); },
|
||||
std::move(then), std::move(ts)...);
|
||||
}
|
||||
|
||||
// Head methods
|
||||
template <typename... Ts>
|
||||
Response Head(Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Head();
|
||||
}
|
||||
|
||||
// Head async methods
|
||||
template <typename... Ts>
|
||||
AsyncResponse HeadAsync(Ts... ts) {
|
||||
return std::async(
|
||||
std::launch::async, [](Ts... ts) { return Head(std::move(ts)...); }, std::move(ts)...);
|
||||
}
|
||||
|
||||
// Head callback methods
|
||||
template <typename Then, typename... Ts>
|
||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||
auto HeadCallback(Then then, Ts... ts) -> std::future<decltype(then(Head(std::move(ts)...)))> {
|
||||
return std::async(
|
||||
std::launch::async, [](Then then, Ts... ts) { return then(Head(std::move(ts)...)); },
|
||||
std::move(then), std::move(ts)...);
|
||||
}
|
||||
|
||||
// Delete methods
|
||||
template <typename... Ts>
|
||||
Response Delete(Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Delete();
|
||||
}
|
||||
|
||||
// Delete async methods
|
||||
template <typename... Ts>
|
||||
AsyncResponse DeleteAsync(Ts... ts) {
|
||||
return std::async(
|
||||
std::launch::async, [](Ts... ts) { return Delete(std::move(ts)...); },
|
||||
std::move(ts)...);
|
||||
}
|
||||
|
||||
// Delete callback methods
|
||||
template <typename Then, typename... Ts>
|
||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||
auto DeleteCallback(Then then, Ts... ts) -> std::future<decltype(then(Delete(std::move(ts)...)))> {
|
||||
return std::async(
|
||||
std::launch::async, [](Then then, Ts... ts) { return then(Delete(std::move(ts)...)); },
|
||||
std::move(then), std::move(ts)...);
|
||||
}
|
||||
|
||||
// Options methods
|
||||
template <typename... Ts>
|
||||
Response Options(Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Options();
|
||||
}
|
||||
|
||||
// Options async methods
|
||||
template <typename... Ts>
|
||||
AsyncResponse OptionsAsync(Ts... ts) {
|
||||
return std::async(
|
||||
std::launch::async, [](Ts... ts) { return Options(std::move(ts)...); },
|
||||
std::move(ts)...);
|
||||
}
|
||||
|
||||
// Options callback methods
|
||||
template <typename Then, typename... Ts>
|
||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||
auto OptionsCallback(Then then, Ts... ts)
|
||||
-> std::future<decltype(then(Options(std::move(ts)...)))> {
|
||||
return std::async(
|
||||
std::launch::async, [](Then then, Ts... ts) { return then(Options(std::move(ts)...)); },
|
||||
std::move(then), std::move(ts)...);
|
||||
}
|
||||
|
||||
// Patch methods
|
||||
template <typename... Ts>
|
||||
Response Patch(Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Patch();
|
||||
}
|
||||
|
||||
// Patch async methods
|
||||
template <typename... Ts>
|
||||
AsyncResponse PatchAsync(Ts... ts) {
|
||||
return std::async(
|
||||
std::launch::async, [](Ts... ts) { return Patch(std::move(ts)...); }, std::move(ts)...);
|
||||
}
|
||||
|
||||
// Patch callback methods
|
||||
template <typename Then, typename... Ts>
|
||||
// NOLINTNEXTLINE(fuchsia-trailing-return)
|
||||
auto PatchCallback(Then then, Ts... ts) -> std::future<decltype(then(Patch(std::move(ts)...)))> {
|
||||
return std::async(
|
||||
std::launch::async, [](Then then, Ts... ts) { return then(Patch(std::move(ts)...)); },
|
||||
std::move(then), std::move(ts)...);
|
||||
}
|
||||
|
||||
// Download methods
|
||||
template <typename... Ts>
|
||||
Response Download(std::ofstream& file, Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Download(file);
|
||||
}
|
||||
|
||||
// Download with user callback
|
||||
template <typename... Ts>
|
||||
Response Download(const WriteCallback& write, Ts&&... ts) {
|
||||
Session session;
|
||||
priv::set_option(session, std::forward<Ts>(ts)...);
|
||||
return session.Download(write);
|
||||
}
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
31
vendor/CPR/include/cpr/auth.h
vendored
31
vendor/CPR/include/cpr/auth.h
vendored
@ -1,31 +0,0 @@
|
||||
#ifndef CPR_AUTH_H
|
||||
#define CPR_AUTH_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class Authentication {
|
||||
public:
|
||||
Authentication(const std::string& username, const std::string& password)
|
||||
: auth_string_{username + ":" + password} {}
|
||||
Authentication(std::string&& username, std::string&& password)
|
||||
: auth_string_{std::move(username) + ":" + std::move(password)} {}
|
||||
Authentication(const Authentication& other) = default;
|
||||
Authentication(Authentication&& old) noexcept = default;
|
||||
virtual ~Authentication() noexcept = default;
|
||||
|
||||
Authentication& operator=(Authentication&& old) noexcept = default;
|
||||
Authentication& operator=(const Authentication& other) = default;
|
||||
|
||||
virtual const char* GetAuthString() const noexcept;
|
||||
|
||||
protected:
|
||||
std::string auth_string_;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
36
vendor/CPR/include/cpr/bearer.h
vendored
36
vendor/CPR/include/cpr/bearer.h
vendored
@ -1,36 +0,0 @@
|
||||
#ifndef CPR_BEARER_H
|
||||
#define CPR_BEARER_H
|
||||
|
||||
#include <string>
|
||||
#include <curl/curlver.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
// Only supported with libcurl >= 7.61.0.
|
||||
// As an alternative use SetHeader and add the token manually.
|
||||
#if LIBCURL_VERSION_NUM >= 0x073D00
|
||||
class Bearer {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Bearer(const std::string& token) : token_string_{token} {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Bearer(std::string&& token) : token_string_{std::move(token)} {}
|
||||
Bearer(const Bearer& other) = default;
|
||||
Bearer(Bearer&& old) noexcept = default;
|
||||
virtual ~Bearer() noexcept = default;
|
||||
|
||||
Bearer& operator=(Bearer&& old) noexcept = default;
|
||||
Bearer& operator=(const Bearer& other) = default;
|
||||
|
||||
virtual const char* GetToken() const noexcept;
|
||||
|
||||
protected:
|
||||
std::string token_string_;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
32
vendor/CPR/include/cpr/body.h
vendored
32
vendor/CPR/include/cpr/body.h
vendored
@ -1,32 +0,0 @@
|
||||
#ifndef CPR_BODY_H
|
||||
#define CPR_BODY_H
|
||||
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
|
||||
#include "cpr/cprtypes.h"
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class Body : public StringHolder<Body> {
|
||||
public:
|
||||
Body() : StringHolder<Body>() {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Body(const std::string& body) : StringHolder<Body>(body) {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Body(std::string&& body) : StringHolder<Body>(std::move(body)) {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Body(const char* body) : StringHolder<Body>(body) {}
|
||||
Body(const char* str, size_t len) : StringHolder<Body>(str, len) {}
|
||||
Body(const std::initializer_list<std::string> args) : StringHolder<Body>(args) {}
|
||||
Body(const Body& other) = default;
|
||||
Body(Body&& old) noexcept = default;
|
||||
~Body() override = default;
|
||||
|
||||
Body& operator=(Body&& old) noexcept = default;
|
||||
Body& operator=(const Body& other) = default;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
78
vendor/CPR/include/cpr/callback.h
vendored
78
vendor/CPR/include/cpr/callback.h
vendored
@ -1,78 +0,0 @@
|
||||
#ifndef CPR_CALLBACK_H
|
||||
#define CPR_CALLBACK_H
|
||||
|
||||
#include "cprtypes.h"
|
||||
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class ReadCallback {
|
||||
public:
|
||||
ReadCallback() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
ReadCallback(std::function<bool(char* buffer, size_t& size)> callback)
|
||||
: size{-1}, callback{std::move(callback)} {}
|
||||
ReadCallback(cpr_off_t size, std::function<bool(char* buffer, size_t& size)> callback)
|
||||
: size{size}, callback{std::move(callback)} {}
|
||||
|
||||
cpr_off_t size{};
|
||||
std::function<bool(char* buffer, size_t& size)> callback;
|
||||
};
|
||||
|
||||
class HeaderCallback {
|
||||
public:
|
||||
HeaderCallback() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
HeaderCallback(std::function<bool(std::string header)> callback)
|
||||
: callback(std::move(callback)) {}
|
||||
|
||||
std::function<bool(std::string header)> callback;
|
||||
};
|
||||
|
||||
class WriteCallback {
|
||||
public:
|
||||
WriteCallback() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
WriteCallback(std::function<bool(std::string data)> callback) : callback(std::move(callback)) {}
|
||||
|
||||
std::function<bool(std::string data)> callback;
|
||||
};
|
||||
|
||||
class ProgressCallback {
|
||||
public:
|
||||
ProgressCallback() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
ProgressCallback(std::function<bool(size_t downloadTotal, size_t downloadNow,
|
||||
size_t uploadTotal, size_t uploadNow)>
|
||||
callback)
|
||||
: callback(std::move(callback)) {}
|
||||
|
||||
std::function<bool(size_t downloadTotal, size_t downloadNow, size_t uploadTotal,
|
||||
size_t uploadNow)>
|
||||
callback;
|
||||
};
|
||||
|
||||
class DebugCallback {
|
||||
public:
|
||||
enum class InfoType {
|
||||
TEXT = 0,
|
||||
HEADER_IN = 1,
|
||||
HEADER_OUT = 2,
|
||||
DATA_IN = 3,
|
||||
DATA_OUT = 4,
|
||||
SSL_DATA_IN = 5,
|
||||
SSL_DATA_OUT = 6,
|
||||
};
|
||||
DebugCallback() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
DebugCallback(std::function<void(InfoType type, std::string data)> callback)
|
||||
: callback(std::move(callback)) {}
|
||||
|
||||
std::function<void(InfoType type, std::string data)> callback;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
18
vendor/CPR/include/cpr/connect_timeout.h
vendored
18
vendor/CPR/include/cpr/connect_timeout.h
vendored
@ -1,18 +0,0 @@
|
||||
#ifndef CPR_CONNECT_TIMEOUT_H
|
||||
#define CPR_CONNECT_TIMEOUT_H
|
||||
|
||||
#include "cpr/timeout.h"
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class ConnectTimeout : public Timeout {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
ConnectTimeout(const std::chrono::milliseconds& duration) : Timeout{duration} {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
ConnectTimeout(const std::int32_t& milliseconds) : Timeout{milliseconds} {}
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
55
vendor/CPR/include/cpr/cookies.h
vendored
55
vendor/CPR/include/cpr/cookies.h
vendored
@ -1,55 +0,0 @@
|
||||
#ifndef CPR_COOKIES_H
|
||||
#define CPR_COOKIES_H
|
||||
|
||||
#include "cpr/curlholder.h"
|
||||
#include <initializer_list>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class Cookies {
|
||||
public:
|
||||
/**
|
||||
* Should we URL-encode cookies when making a request.
|
||||
* Based on RFC6265, it is recommended but not mandatory to encode cookies.
|
||||
*
|
||||
* -------
|
||||
* To maximize compatibility with user agents, servers that wish to
|
||||
* store arbitrary data in a cookie-value SHOULD encode that data, for
|
||||
* example, using Base64 [RFC4648].
|
||||
* -------
|
||||
* Source: RFC6265 (https://www.ietf.org/rfc/rfc6265.txt)
|
||||
**/
|
||||
bool encode{true};
|
||||
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Cookies(bool encode = true) : encode(encode) {}
|
||||
Cookies(const std::initializer_list<std::pair<const std::string, std::string>>& pairs,
|
||||
bool encode = true)
|
||||
: encode(encode), map_{pairs} {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Cookies(const std::map<std::string, std::string>& map, bool encode = true)
|
||||
: encode(encode), map_{map} {}
|
||||
|
||||
std::string& operator[](const std::string& key);
|
||||
std::string GetEncoded(const CurlHolder& holder) const;
|
||||
|
||||
using iterator = std::map<std::string, std::string>::iterator;
|
||||
using const_iterator = std::map<std::string, std::string>::const_iterator;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
const_iterator cbegin() const;
|
||||
const_iterator cend() const;
|
||||
|
||||
protected:
|
||||
std::map<std::string, std::string> map_;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
13
vendor/CPR/include/cpr/cpr.h
vendored
13
vendor/CPR/include/cpr/cpr.h
vendored
@ -1,13 +0,0 @@
|
||||
#ifndef CPR_CPR_H
|
||||
#define CPR_CPR_H
|
||||
|
||||
#include "cpr/api.h"
|
||||
#include "cpr/auth.h"
|
||||
#include "cpr/cprtypes.h"
|
||||
#include "cpr/response.h"
|
||||
#include "cpr/session.h"
|
||||
#include "cpr/status_codes.h"
|
||||
|
||||
#define CPR_LIBCURL_VERSION_NUM LIBCURL_VERSION_NUM
|
||||
|
||||
#endif
|
133
vendor/CPR/include/cpr/cprtypes.h
vendored
133
vendor/CPR/include/cpr/cprtypes.h
vendored
@ -1,133 +0,0 @@
|
||||
#ifndef CPR_CPR_TYPES_H
|
||||
#define CPR_CPR_TYPES_H
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <initializer_list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
/**
|
||||
* Wrapper around "curl_off_t" to prevent applications from having to link against libcurl.
|
||||
**/
|
||||
using cpr_off_t = curl_off_t;
|
||||
|
||||
template <class T>
|
||||
class StringHolder {
|
||||
public:
|
||||
StringHolder() = default;
|
||||
explicit StringHolder(const std::string& str) : str_(str) {}
|
||||
explicit StringHolder(std::string&& str) : str_(std::move(str)) {}
|
||||
explicit StringHolder(const char* str) : str_(str) {}
|
||||
StringHolder(const char* str, size_t len) : str_(str, len) {}
|
||||
StringHolder(const std::initializer_list<std::string> args) {
|
||||
str_ = std::accumulate(args.begin(), args.end(), str_);
|
||||
}
|
||||
StringHolder(const StringHolder& other) = default;
|
||||
StringHolder(StringHolder&& old) noexcept = default;
|
||||
virtual ~StringHolder() = default;
|
||||
|
||||
StringHolder& operator=(StringHolder&& old) noexcept = default;
|
||||
|
||||
StringHolder& operator=(const StringHolder& other) = default;
|
||||
|
||||
explicit operator std::string() const {
|
||||
return str_;
|
||||
}
|
||||
|
||||
T operator+(const char* rhs) const {
|
||||
return T(str_ + rhs);
|
||||
}
|
||||
|
||||
T operator+(const std::string& rhs) const {
|
||||
return T(str_ + rhs);
|
||||
}
|
||||
|
||||
T operator+(const StringHolder<T>& rhs) const {
|
||||
return T(str_ + rhs.str_);
|
||||
}
|
||||
|
||||
void operator+=(const char* rhs) {
|
||||
str_ += rhs;
|
||||
}
|
||||
void operator+=(const std::string& rhs) {
|
||||
str_ += rhs;
|
||||
}
|
||||
void operator+=(const StringHolder<T>& rhs) {
|
||||
str_ += rhs;
|
||||
}
|
||||
|
||||
bool operator==(const char* rhs) const {
|
||||
return str_ == rhs;
|
||||
}
|
||||
bool operator==(const std::string& rhs) const {
|
||||
return str_ == rhs;
|
||||
}
|
||||
bool operator==(const StringHolder<T>& rhs) const {
|
||||
return str_ == rhs.str_;
|
||||
}
|
||||
|
||||
bool operator!=(const char* rhs) const {
|
||||
return str_.c_str() != rhs;
|
||||
}
|
||||
bool operator!=(const std::string& rhs) const {
|
||||
return str_ != rhs;
|
||||
}
|
||||
bool operator!=(const StringHolder<T>& rhs) const {
|
||||
return str_ != rhs.str_;
|
||||
}
|
||||
|
||||
const std::string& str() {
|
||||
return str_;
|
||||
}
|
||||
const std::string& str() const {
|
||||
return str_;
|
||||
}
|
||||
const char* c_str() const {
|
||||
return str_.c_str();
|
||||
}
|
||||
const char* data() const {
|
||||
return str_.data();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string str_{};
|
||||
};
|
||||
|
||||
template <class T>
|
||||
std::ostream& operator<<(std::ostream& os, const StringHolder<T>& s) {
|
||||
os << s.str();
|
||||
return os;
|
||||
}
|
||||
|
||||
class Url : public StringHolder<Url> {
|
||||
public:
|
||||
Url() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Url(const std::string& url) : StringHolder<Url>(url) {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Url(std::string&& url) : StringHolder<Url>(std::move(url)) {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Url(const char* url) : StringHolder<Url>(url) {}
|
||||
Url(const char* str, size_t len) : StringHolder<Url>(std::string(str, len)) {}
|
||||
Url(const std::initializer_list<std::string> args) : StringHolder<Url>(args) {}
|
||||
Url(const Url& other) = default;
|
||||
Url(Url&& old) noexcept = default;
|
||||
~Url() override = default;
|
||||
|
||||
Url& operator=(Url&& old) noexcept = default;
|
||||
Url& operator=(const Url& other) = default;
|
||||
};
|
||||
|
||||
struct CaseInsensitiveCompare {
|
||||
bool operator()(const std::string& a, const std::string& b) const noexcept;
|
||||
};
|
||||
|
||||
using Header = std::map<std::string, std::string, CaseInsensitiveCompare>;
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
50
vendor/CPR/include/cpr/curl_container.h
vendored
50
vendor/CPR/include/cpr/curl_container.h
vendored
@ -1,50 +0,0 @@
|
||||
#ifndef CURL_CONTAINER_H
|
||||
#define CURL_CONTAINER_H
|
||||
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cpr/curlholder.h"
|
||||
|
||||
|
||||
namespace cpr {
|
||||
|
||||
struct Parameter {
|
||||
Parameter(const std::string& key, const std::string& value) : key{key}, value{value} {}
|
||||
Parameter(std::string&& key, std::string&& value)
|
||||
: key{std::move(key)}, value{std::move(value)} {}
|
||||
|
||||
std::string key;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
struct Pair {
|
||||
Pair(const std::string& p_key, const std::string& p_value) : key(p_key), value(p_value) {}
|
||||
Pair(std::string&& p_key, std::string&& p_value)
|
||||
: key(std::move(p_key)), value(std::move(p_value)) {}
|
||||
|
||||
std::string key;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class CurlContainer {
|
||||
public:
|
||||
CurlContainer() = default;
|
||||
CurlContainer(const std::initializer_list<T>&);
|
||||
|
||||
void Add(const std::initializer_list<T>&);
|
||||
void Add(const T&);
|
||||
|
||||
const std::string GetContent(const CurlHolder&) const;
|
||||
|
||||
protected:
|
||||
std::vector<T> containerList_;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif //
|
50
vendor/CPR/include/cpr/curlholder.h
vendored
50
vendor/CPR/include/cpr/curlholder.h
vendored
@ -1,50 +0,0 @@
|
||||
#ifndef CPR_CURL_HOLDER_H
|
||||
#define CPR_CURL_HOLDER_H
|
||||
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
namespace cpr {
|
||||
struct CurlHolder {
|
||||
private:
|
||||
/**
|
||||
* Mutex for curl_easy_init().
|
||||
* curl_easy_init() is not thread save.
|
||||
* References:
|
||||
* https://curl.haxx.se/libcurl/c/curl_easy_init.html
|
||||
* https://curl.haxx.se/libcurl/c/threadsafe.html
|
||||
**/
|
||||
// It does not make sense to make a std::mutex const.
|
||||
// NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static std::mutex curl_easy_init_mutex_;
|
||||
|
||||
public:
|
||||
CURL* handle{nullptr};
|
||||
struct curl_slist* chunk{nullptr};
|
||||
struct curl_httppost* formpost{nullptr};
|
||||
std::array<char, CURL_ERROR_SIZE> error{};
|
||||
|
||||
CurlHolder();
|
||||
CurlHolder(const CurlHolder& other) = default;
|
||||
CurlHolder(CurlHolder&& old) noexcept = default;
|
||||
~CurlHolder();
|
||||
|
||||
CurlHolder& operator=(CurlHolder&& old) noexcept = default;
|
||||
CurlHolder& operator=(const CurlHolder& other) = default;
|
||||
|
||||
/**
|
||||
* Uses curl_easy_escape(...) for escaping the given string.
|
||||
**/
|
||||
std::string urlEncode(const std::string& s) const;
|
||||
|
||||
/**
|
||||
* Uses curl_easy_unescape(...) for unescaping the given string.
|
||||
**/
|
||||
std::string urlDecode(const std::string& s) const;
|
||||
};
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
15
vendor/CPR/include/cpr/digest.h
vendored
15
vendor/CPR/include/cpr/digest.h
vendored
@ -1,15 +0,0 @@
|
||||
#ifndef CPR_DIGEST_H
|
||||
#define CPR_DIGEST_H
|
||||
|
||||
#include "cpr/auth.h"
|
||||
|
||||
namespace cpr {
|
||||
class Digest : public Authentication {
|
||||
public:
|
||||
Digest(const std::string& username, const std::string& password)
|
||||
: Authentication{username, password} {}
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
54
vendor/CPR/include/cpr/error.h
vendored
54
vendor/CPR/include/cpr/error.h
vendored
@ -1,54 +0,0 @@
|
||||
#ifndef CPR_ERROR_H
|
||||
#define CPR_ERROR_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "cpr/cprtypes.h"
|
||||
#include <utility>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
enum class ErrorCode {
|
||||
OK = 0,
|
||||
CONNECTION_FAILURE,
|
||||
EMPTY_RESPONSE,
|
||||
HOST_RESOLUTION_FAILURE,
|
||||
INTERNAL_ERROR,
|
||||
INVALID_URL_FORMAT,
|
||||
NETWORK_RECEIVE_ERROR,
|
||||
NETWORK_SEND_FAILURE,
|
||||
OPERATION_TIMEDOUT,
|
||||
PROXY_RESOLUTION_FAILURE,
|
||||
SSL_CONNECT_ERROR,
|
||||
SSL_LOCAL_CERTIFICATE_ERROR,
|
||||
SSL_REMOTE_CERTIFICATE_ERROR,
|
||||
SSL_CACERT_ERROR,
|
||||
GENERIC_SSL_ERROR,
|
||||
UNSUPPORTED_PROTOCOL,
|
||||
REQUEST_CANCELLED,
|
||||
UNKNOWN_ERROR = 1000,
|
||||
};
|
||||
|
||||
class Error {
|
||||
public:
|
||||
ErrorCode code = ErrorCode::OK;
|
||||
std::string message{};
|
||||
|
||||
Error() = default;
|
||||
|
||||
Error(const std::int32_t& curl_code, std::string&& p_error_message)
|
||||
: code{getErrorCodeForCurlError(curl_code)},
|
||||
message(std::move(p_error_message)) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return code != ErrorCode::OK;
|
||||
}
|
||||
|
||||
private:
|
||||
static ErrorCode getErrorCodeForCurlError(std::int32_t curl_code);
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
19
vendor/CPR/include/cpr/limit_rate.h
vendored
19
vendor/CPR/include/cpr/limit_rate.h
vendored
@ -1,19 +0,0 @@
|
||||
#ifndef CPR_SPEED_LIMIT_H
|
||||
#define CPR_SPEED_LIMIT_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class LimitRate {
|
||||
public:
|
||||
LimitRate(const std::int64_t downrate, const std::int64_t uprate)
|
||||
: downrate(downrate), uprate(uprate) {}
|
||||
|
||||
std::int64_t downrate = 0;
|
||||
std::int64_t uprate = 0;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
18
vendor/CPR/include/cpr/low_speed.h
vendored
18
vendor/CPR/include/cpr/low_speed.h
vendored
@ -1,18 +0,0 @@
|
||||
#ifndef CPR_LOW_SPEED_H
|
||||
#define CPR_LOW_SPEED_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class LowSpeed {
|
||||
public:
|
||||
LowSpeed(const std::int32_t limit, const std::int32_t time) : limit(limit), time(time) {}
|
||||
|
||||
std::int32_t limit;
|
||||
std::int32_t time;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
18
vendor/CPR/include/cpr/max_redirects.h
vendored
18
vendor/CPR/include/cpr/max_redirects.h
vendored
@ -1,18 +0,0 @@
|
||||
#ifndef CPR_MAX_REDIRECTS_H
|
||||
#define CPR_MAX_REDIRECTS_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class MaxRedirects {
|
||||
public:
|
||||
explicit MaxRedirects(const std::int32_t number_of_redirects)
|
||||
: number_of_redirects(number_of_redirects) {}
|
||||
|
||||
std::int32_t number_of_redirects;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
79
vendor/CPR/include/cpr/multipart.h
vendored
79
vendor/CPR/include/cpr/multipart.h
vendored
@ -1,79 +0,0 @@
|
||||
#ifndef CPR_MULTIPART_H
|
||||
#define CPR_MULTIPART_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
struct File {
|
||||
explicit File(std::string&& filepath) : filepath(std::move(filepath)) {}
|
||||
explicit File(const std::string& filepath) : filepath(filepath) {}
|
||||
const std::string filepath;
|
||||
};
|
||||
|
||||
struct Buffer {
|
||||
using data_t = const unsigned char*;
|
||||
|
||||
template <typename Iterator>
|
||||
Buffer(Iterator begin, Iterator end, std::string&& filename)
|
||||
// Ignored here since libcurl reqires a long.
|
||||
// There is also no way around the reinterpret_cast.
|
||||
// NOLINTNEXTLINE(google-runtime-int, cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
: data{reinterpret_cast<data_t>(&(*begin))}, datalen{static_cast<long>(
|
||||
std::distance(begin, end))},
|
||||
filename(std::move(filename)) {
|
||||
is_random_access_iterator(begin, end);
|
||||
static_assert(sizeof(*begin) == 1, "only byte buffers can be used");
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
typename std::enable_if<std::is_same<typename std::iterator_traits<Iterator>::iterator_category,
|
||||
std::random_access_iterator_tag>::value>::type
|
||||
is_random_access_iterator(Iterator /* begin */, Iterator /* end */) {}
|
||||
|
||||
data_t data;
|
||||
// Ignored here since libcurl reqires a long:
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
long datalen;
|
||||
const std::string filename;
|
||||
};
|
||||
|
||||
struct Part {
|
||||
Part(const std::string& name, const std::string& value, const std::string& content_type = {})
|
||||
: name{name}, value{value},
|
||||
content_type{content_type}, is_file{false}, is_buffer{false} {}
|
||||
Part(const std::string& name, const std::int32_t& value, const std::string& content_type = {})
|
||||
: name{name}, value{std::to_string(value)},
|
||||
content_type{content_type}, is_file{false}, is_buffer{false} {}
|
||||
Part(const std::string& name, const File& file, const std::string& content_type = {})
|
||||
: name{name}, value{file.filepath},
|
||||
content_type{content_type}, is_file{true}, is_buffer{false} {}
|
||||
Part(const std::string& name, const Buffer& buffer, const std::string& content_type = {})
|
||||
: name{name}, value{buffer.filename}, content_type{content_type}, data{buffer.data},
|
||||
datalen{buffer.datalen}, is_file{false}, is_buffer{true} {}
|
||||
|
||||
std::string name;
|
||||
std::string value;
|
||||
std::string content_type;
|
||||
Buffer::data_t data{nullptr};
|
||||
// Ignored here since libcurl reqires a long:
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
long datalen{0};
|
||||
bool is_file;
|
||||
bool is_buffer;
|
||||
};
|
||||
|
||||
class Multipart {
|
||||
public:
|
||||
Multipart(const std::initializer_list<Part>& parts);
|
||||
|
||||
std::vector<Part> parts;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
15
vendor/CPR/include/cpr/ntlm.h
vendored
15
vendor/CPR/include/cpr/ntlm.h
vendored
@ -1,15 +0,0 @@
|
||||
#ifndef CPR_NTLM_H
|
||||
#define CPR_NTLM_H
|
||||
|
||||
#include "cpr/auth.h"
|
||||
|
||||
namespace cpr {
|
||||
class NTLM : public Authentication {
|
||||
public:
|
||||
NTLM(const std::string& username, const std::string& password)
|
||||
: Authentication{username, password} {}
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
20
vendor/CPR/include/cpr/parameters.h
vendored
20
vendor/CPR/include/cpr/parameters.h
vendored
@ -1,20 +0,0 @@
|
||||
#ifndef CPR_PARAMETERS_H
|
||||
#define CPR_PARAMETERS_H
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
#include "cpr/curl_container.h"
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class Parameters : public CurlContainer<Parameter> {
|
||||
protected:
|
||||
using CurlContainer<Parameter>::containerList_;
|
||||
public:
|
||||
Parameters() = default;
|
||||
Parameters(const std::initializer_list<Parameter>& parameters);
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
25
vendor/CPR/include/cpr/payload.h
vendored
25
vendor/CPR/include/cpr/payload.h
vendored
@ -1,25 +0,0 @@
|
||||
#ifndef CPR_PAYLOAD_H
|
||||
#define CPR_PAYLOAD_H
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
#include "cpr/curl_container.h"
|
||||
|
||||
|
||||
namespace cpr {
|
||||
class Payload : public CurlContainer<Pair> {
|
||||
protected:
|
||||
using CurlContainer<Pair>::containerList_;
|
||||
public:
|
||||
template <class It>
|
||||
Payload(const It begin, const It end) {
|
||||
for (It pair = begin; pair != end; ++pair) {
|
||||
Add(*pair);
|
||||
}
|
||||
}
|
||||
Payload(const std::initializer_list<Pair>& pairs);
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
22
vendor/CPR/include/cpr/proxies.h
vendored
22
vendor/CPR/include/cpr/proxies.h
vendored
@ -1,22 +0,0 @@
|
||||
#ifndef CPR_PROXIES_H
|
||||
#define CPR_PROXIES_H
|
||||
|
||||
#include <initializer_list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace cpr {
|
||||
class Proxies {
|
||||
public:
|
||||
Proxies() = default;
|
||||
Proxies(const std::initializer_list<std::pair<const std::string, std::string>>& hosts);
|
||||
|
||||
bool has(const std::string& protocol) const;
|
||||
const std::string& operator[](const std::string& protocol);
|
||||
|
||||
protected:
|
||||
std::map<std::string, std::string> hosts_;
|
||||
};
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
56
vendor/CPR/include/cpr/response.h
vendored
56
vendor/CPR/include/cpr/response.h
vendored
@ -1,56 +0,0 @@
|
||||
#ifndef CPR_RESPONSE_H
|
||||
#define CPR_RESPONSE_H
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <curl/curl.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cpr/cookies.h"
|
||||
#include "cpr/cprtypes.h"
|
||||
#include "cpr/error.h"
|
||||
#include "cpr/ssl_options.h"
|
||||
#include "cpr/util.h"
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class Response {
|
||||
protected:
|
||||
std::shared_ptr<CurlHolder> curl_{nullptr};
|
||||
|
||||
public:
|
||||
// Ignored here since libcurl uses a long for this.
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
long status_code{};
|
||||
std::string text{};
|
||||
Header header{};
|
||||
Url url{};
|
||||
double elapsed{};
|
||||
Cookies cookies{};
|
||||
Error error{};
|
||||
std::string raw_header{};
|
||||
std::string status_line{};
|
||||
std::string reason{};
|
||||
cpr_off_t uploaded_bytes{};
|
||||
cpr_off_t downloaded_bytes{};
|
||||
// Ignored here since libcurl uses a long for this.
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
long redirect_count{};
|
||||
|
||||
Response() = default;
|
||||
Response(std::shared_ptr<CurlHolder> curl, std::string&& p_text, std::string&& p_header_string,
|
||||
Cookies&& p_cookies, Error&& p_error);
|
||||
std::vector<std::string> GetCertInfo();
|
||||
Response(const Response& other) = default;
|
||||
Response(Response&& old) noexcept = default;
|
||||
~Response() noexcept = default;
|
||||
|
||||
Response& operator=(Response&& old) noexcept = default;
|
||||
Response& operator=(const Response& other) = default;
|
||||
};
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
132
vendor/CPR/include/cpr/session.h
vendored
132
vendor/CPR/include/cpr/session.h
vendored
@ -1,132 +0,0 @@
|
||||
#ifndef CPR_SESSION_H
|
||||
#define CPR_SESSION_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
#include "cpr/auth.h"
|
||||
#include "cpr/bearer.h"
|
||||
#include "cpr/body.h"
|
||||
#include "cpr/callback.h"
|
||||
#include "cpr/connect_timeout.h"
|
||||
#include "cpr/cookies.h"
|
||||
#include "cpr/cprtypes.h"
|
||||
#include "cpr/digest.h"
|
||||
#include "cpr/limit_rate.h"
|
||||
#include "cpr/low_speed.h"
|
||||
#include "cpr/max_redirects.h"
|
||||
#include "cpr/multipart.h"
|
||||
#include "cpr/ntlm.h"
|
||||
#include "cpr/parameters.h"
|
||||
#include "cpr/payload.h"
|
||||
#include "cpr/proxies.h"
|
||||
#include "cpr/response.h"
|
||||
#include "cpr/ssl_options.h"
|
||||
#include "cpr/timeout.h"
|
||||
#include "cpr/unix_socket.h"
|
||||
#include "cpr/user_agent.h"
|
||||
#include "cpr/verbose.h"
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class Session {
|
||||
public:
|
||||
Session();
|
||||
Session(Session&& old) noexcept = default;
|
||||
Session(const Session& other) = delete;
|
||||
|
||||
~Session();
|
||||
|
||||
Session& operator=(Session&& old) noexcept = default;
|
||||
Session& operator=(const Session& other) = delete;
|
||||
|
||||
void SetUrl(const Url& url);
|
||||
void SetParameters(const Parameters& parameters);
|
||||
void SetParameters(Parameters&& parameters);
|
||||
void SetHeader(const Header& header);
|
||||
void SetTimeout(const Timeout& timeout);
|
||||
void SetConnectTimeout(const ConnectTimeout& timeout);
|
||||
void SetAuth(const Authentication& auth);
|
||||
void SetDigest(const Digest& auth);
|
||||
void SetUserAgent(const UserAgent& ua);
|
||||
void SetPayload(Payload&& payload);
|
||||
void SetPayload(const Payload& payload);
|
||||
void SetProxies(Proxies&& proxies);
|
||||
void SetProxies(const Proxies& proxies);
|
||||
void SetMultipart(Multipart&& multipart);
|
||||
void SetMultipart(const Multipart& multipart);
|
||||
void SetNTLM(const NTLM& auth);
|
||||
void SetRedirect(const bool& redirect);
|
||||
void SetMaxRedirects(const MaxRedirects& max_redirects);
|
||||
void SetCookies(const Cookies& cookies);
|
||||
void SetBody(Body&& body);
|
||||
void SetBody(const Body& body);
|
||||
void SetLowSpeed(const LowSpeed& low_speed);
|
||||
void SetVerifySsl(const VerifySsl& verify);
|
||||
void SetUnixSocket(const UnixSocket& unix_socket);
|
||||
void SetSslOptions(const SslOptions& options);
|
||||
void SetReadCallback(const ReadCallback& read);
|
||||
void SetHeaderCallback(const HeaderCallback& header);
|
||||
void SetWriteCallback(const WriteCallback& write);
|
||||
void SetProgressCallback(const ProgressCallback& progress);
|
||||
void SetDebugCallback(const DebugCallback& debug);
|
||||
void SetVerbose(const Verbose& verbose);
|
||||
|
||||
// Used in templated functions
|
||||
void SetOption(const Url& url);
|
||||
void SetOption(const Parameters& parameters);
|
||||
void SetOption(Parameters&& parameters);
|
||||
void SetOption(const Header& header);
|
||||
void SetOption(const Timeout& timeout);
|
||||
void SetOption(const ConnectTimeout& timeout);
|
||||
void SetOption(const Authentication& auth);
|
||||
// Only supported with libcurl >= 7.61.0.
|
||||
// As an alternative use SetHeader and add the token manually.
|
||||
#if LIBCURL_VERSION_NUM >= 0x073D00
|
||||
void SetOption(const Bearer& auth);
|
||||
#endif
|
||||
void SetOption(const Digest& auth);
|
||||
void SetOption(const UserAgent& ua);
|
||||
void SetOption(Payload&& payload);
|
||||
void SetOption(const Payload& payload);
|
||||
void SetOption(const LimitRate& limit_rate);
|
||||
void SetOption(Proxies&& proxies);
|
||||
void SetOption(const Proxies& proxies);
|
||||
void SetOption(Multipart&& multipart);
|
||||
void SetOption(const Multipart& multipart);
|
||||
void SetOption(const NTLM& auth);
|
||||
void SetOption(const bool& redirect);
|
||||
void SetOption(const MaxRedirects& max_redirects);
|
||||
void SetOption(const Cookies& cookies);
|
||||
void SetOption(Body&& body);
|
||||
void SetOption(const Body& body);
|
||||
void SetOption(const ReadCallback& read);
|
||||
void SetOption(const HeaderCallback& header);
|
||||
void SetOption(const WriteCallback& write);
|
||||
void SetOption(const ProgressCallback& progress);
|
||||
void SetOption(const DebugCallback& debug);
|
||||
void SetOption(const LowSpeed& low_speed);
|
||||
void SetOption(const VerifySsl& verify);
|
||||
void SetOption(const Verbose& verbose);
|
||||
void SetOption(const UnixSocket& unix_socket);
|
||||
void SetOption(const SslOptions& options);
|
||||
|
||||
Response Delete();
|
||||
Response Download(const WriteCallback& write);
|
||||
Response Download(std::ofstream& file);
|
||||
Response Get();
|
||||
Response Head();
|
||||
Response Options();
|
||||
Response Patch();
|
||||
Response Post();
|
||||
Response Put();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> pimpl_;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
516
vendor/CPR/include/cpr/ssl_options.h
vendored
516
vendor/CPR/include/cpr/ssl_options.h
vendored
@ -1,516 +0,0 @@
|
||||
#ifndef CPR_SSLOPTIONS_H
|
||||
#define CPR_SSLOPTIONS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#define __LIBCURL_VERSION_GTE(major, minor) \
|
||||
((LIBCURL_VERSION_MAJOR > (major)) || \
|
||||
((LIBCURL_VERSION_MAJOR == (major)) && (LIBCURL_VERSION_MINOR >= (minor))))
|
||||
#define __LIBCURL_VERSION_LT(major, minor) \
|
||||
((LIBCURL_VERSION_MAJOR < (major)) || \
|
||||
((LIBCURL_VERSION_MAJOR == (major)) && (LIBCURL_VERSION_MINOR < (minor))))
|
||||
|
||||
#ifndef SUPPORT_ALPN
|
||||
#define SUPPORT_ALPN __LIBCURL_VERSION_GTE(7, 36)
|
||||
#endif
|
||||
#ifndef SUPPORT_NPN
|
||||
#define SUPPORT_NPN __LIBCURL_VERSION_GTE(7, 36)
|
||||
#endif
|
||||
|
||||
#ifndef SUPPORT_SSLv2
|
||||
#define SUPPORT_SSLv2 __LIBCURL_VERSION_LT(7, 19)
|
||||
#endif
|
||||
#ifndef SUPPORT_SSLv3
|
||||
#define SUPPORT_SSLv3 __LIBCURL_VERSION_LT(7, 39)
|
||||
#endif
|
||||
#ifndef SUPPORT_TLSv1_0
|
||||
#define SUPPORT_TLSv1_0 __LIBCURL_VERSION_GTE(7, 34)
|
||||
#endif
|
||||
#ifndef SUPPORT_TLSv1_1
|
||||
#define SUPPORT_TLSv1_1 __LIBCURL_VERSION_GTE(7, 34)
|
||||
#endif
|
||||
#ifndef SUPPORT_TLSv1_2
|
||||
#define SUPPORT_TLSv1_2 __LIBCURL_VERSION_GTE(7, 34)
|
||||
#endif
|
||||
#ifndef SUPPORT_TLSv1_3
|
||||
#define SUPPORT_TLSv1_3 __LIBCURL_VERSION_GTE(7, 52)
|
||||
#endif
|
||||
#ifndef SUPPORT_MAX_TLS_VERSION
|
||||
#define SUPPORT_MAX_TLS_VERSION __LIBCURL_VERSION_GTE(7, 54)
|
||||
#endif
|
||||
#ifndef SUPPORT_MAX_TLSv1_1
|
||||
#define SUPPORT_MAX_TLSv1_1 __LIBCURL_VERSION_GTE(7, 54)
|
||||
#endif
|
||||
#ifndef SUPPORT_MAX_TLSv1_2
|
||||
#define SUPPORT_MAX_TLSv1_2 __LIBCURL_VERSION_GTE(7, 54)
|
||||
#endif
|
||||
#ifndef SUPPORT_MAX_TLSv1_3
|
||||
#define SUPPORT_MAX_TLSv1_3 __LIBCURL_VERSION_GTE(7, 54)
|
||||
#endif
|
||||
#ifndef SUPPORT_TLSv13_CIPHERS
|
||||
#define SUPPORT_TLSv13_CIPHERS __LIBCURL_VERSION_GTE(7, 61)
|
||||
#endif
|
||||
#ifndef SUPPORT_SESSIONID_CACHE
|
||||
#define SUPPORT_SESSIONID_CACHE __LIBCURL_VERSION_GTE(7, 16)
|
||||
#endif
|
||||
#ifndef SUPPORT_SSL_FALSESTART
|
||||
#define SUPPORT_SSL_FALSESTART __LIBCURL_VERSION_GTE(7, 42)
|
||||
#endif
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class VerifySsl {
|
||||
public:
|
||||
VerifySsl() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
VerifySsl(bool verify) : verify(verify) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return verify;
|
||||
}
|
||||
|
||||
bool verify = true;
|
||||
};
|
||||
|
||||
namespace ssl {
|
||||
|
||||
// set SSL client certificate
|
||||
class CertFile {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
CertFile(std::string&& p_filename) : filename(std::move(p_filename)) {}
|
||||
|
||||
const std::string filename;
|
||||
|
||||
virtual const char* GetCertType() const {
|
||||
return "PEM";
|
||||
}
|
||||
};
|
||||
|
||||
using PemCert = CertFile;
|
||||
|
||||
class DerCert : public CertFile {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
DerCert(std::string&& p_filename) : CertFile(std::move(p_filename)) {}
|
||||
|
||||
const char* GetCertType() const override {
|
||||
return "DER";
|
||||
}
|
||||
};
|
||||
|
||||
// specify private keyfile for TLS and SSL client cert
|
||||
class KeyFile {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
KeyFile(std::string&& p_filename) : filename(std::move(p_filename)) {}
|
||||
|
||||
template <typename FileType, typename PassType>
|
||||
KeyFile(FileType&& p_filename, PassType p_password)
|
||||
: filename(std::forward<FileType>(p_filename)), password(std::move(p_password)) {}
|
||||
|
||||
std::string filename;
|
||||
std::string password;
|
||||
|
||||
virtual const char* GetKeyType() const {
|
||||
return "PEM";
|
||||
}
|
||||
};
|
||||
|
||||
using PemKey = KeyFile;
|
||||
|
||||
class DerKey : public KeyFile {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
DerKey(std::string&& p_filename) : KeyFile(std::move(p_filename)) {}
|
||||
|
||||
template <typename FileType, typename PassType>
|
||||
DerKey(FileType&& p_filename, PassType p_password)
|
||||
: KeyFile(std::forward<FileType>(p_filename), std::move(p_password)) {}
|
||||
|
||||
const char* GetKeyType() const override {
|
||||
return "DER";
|
||||
}
|
||||
};
|
||||
|
||||
#if SUPPORT_ALPN
|
||||
// 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.
|
||||
class ALPN {
|
||||
public:
|
||||
ALPN() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
ALPN(bool enabled) : enabled(enabled) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool enabled = true;
|
||||
};
|
||||
#endif // SUPPORT_ALPN
|
||||
|
||||
#if SUPPORT_NPN
|
||||
// This option enables/disables NPN in the SSL handshake (if the SSL backend libcurl is built to
|
||||
// use supports it), which can be used to negotiate http2.
|
||||
class NPN {
|
||||
public:
|
||||
NPN() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
NPN(bool enabled) : enabled(enabled) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool enabled = true;
|
||||
};
|
||||
#endif // SUPPORT_NPN
|
||||
|
||||
// This option determines whether libcurl verifies that the server cert is for the server it is
|
||||
// known as.
|
||||
class VerifyHost {
|
||||
public:
|
||||
VerifyHost() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
VerifyHost(bool enabled) : enabled(enabled) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool enabled = true;
|
||||
};
|
||||
|
||||
// This option determines whether libcurl verifies the authenticity of the peer's certificate.
|
||||
class VerifyPeer {
|
||||
public:
|
||||
VerifyPeer() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
VerifyPeer(bool enabled) : enabled(enabled) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool enabled = true;
|
||||
};
|
||||
|
||||
// This option determines whether libcurl verifies the status of the server cert using the
|
||||
// "Certificate Status Request" TLS extension (aka. OCSP stapling).
|
||||
class VerifyStatus {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
VerifyStatus(bool enabled) : enabled(enabled) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
// TLS v1.0 or later
|
||||
struct TLSv1 {};
|
||||
#if SUPPORT_SSLv2
|
||||
// SSL v2 (but not SSLv3)
|
||||
struct SSLv2 {};
|
||||
#endif
|
||||
#if SUPPORT_SSLv3
|
||||
// SSL v3 (but not SSLv2)
|
||||
struct SSLv3 {};
|
||||
#endif
|
||||
#if SUPPORT_TLSv1_0
|
||||
// TLS v1.0 or later (Added in 7.34.0)
|
||||
struct TLSv1_0 {};
|
||||
#endif
|
||||
#if SUPPORT_TLSv1_1
|
||||
// TLS v1.1 or later (Added in 7.34.0)
|
||||
struct TLSv1_1 {};
|
||||
#endif
|
||||
#if SUPPORT_TLSv1_2
|
||||
// TLS v1.2 or later (Added in 7.34.0)
|
||||
struct TLSv1_2 {};
|
||||
#endif
|
||||
#if SUPPORT_TLSv1_3
|
||||
// TLS v1.3 or later (Added in 7.52.0)
|
||||
struct TLSv1_3 {};
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLS_VERSION
|
||||
// The flag defines the maximum supported TLS version by libcurl, or the default value from the SSL
|
||||
// library is used.
|
||||
struct MaxTLSVersion {};
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLSv1_0
|
||||
// The flag defines maximum supported TLS version as TLSv1.0. (Added in 7.54.0)
|
||||
struct MaxTLSv1_0 {};
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLSv1_1
|
||||
// The flag defines maximum supported TLS version as TLSv1.1. (Added in 7.54.0)
|
||||
struct MaxTLSv1_1 {};
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLSv1_2
|
||||
// The flag defines maximum supported TLS version as TLSv1.2. (Added in 7.54.0)
|
||||
struct MaxTLSv1_2 {};
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLSv1_3
|
||||
// The flag defines maximum supported TLS version as TLSv1.3. (Added in 7.54.0)
|
||||
struct MaxTLSv1_3 {};
|
||||
#endif
|
||||
|
||||
// path to Certificate Authority (CA) bundle
|
||||
class CaInfo {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
CaInfo(std::string&& p_filename) : filename(std::move(p_filename)) {}
|
||||
|
||||
std::string filename;
|
||||
};
|
||||
|
||||
// specify directory holding CA certificates
|
||||
class CaPath {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
CaPath(std::string&& p_filename) : filename(std::move(p_filename)) {}
|
||||
|
||||
std::string filename;
|
||||
};
|
||||
|
||||
// specify a Certificate Revocation List file
|
||||
class Crl {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Crl(std::string&& p_filename) : filename(std::move(p_filename)) {}
|
||||
|
||||
std::string filename;
|
||||
};
|
||||
|
||||
// specify ciphers to use for TLS
|
||||
class Ciphers {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Ciphers(std::string&& p_ciphers) : ciphers(std::move(p_ciphers)) {}
|
||||
|
||||
std::string ciphers;
|
||||
};
|
||||
|
||||
#if SUPPORT_TLSv13_CIPHERS
|
||||
// specify ciphers suites to use for TLS 1.3
|
||||
class TLS13_Ciphers {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
TLS13_Ciphers(std::string&& p_ciphers) : ciphers(std::move(p_ciphers)) {}
|
||||
|
||||
std::string ciphers;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if SUPPORT_SESSIONID_CACHE
|
||||
// enable/disable use of the SSL session-ID cache
|
||||
class SessionIdCache {
|
||||
public:
|
||||
SessionIdCache() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
SessionIdCache(bool enabled) : enabled(enabled) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool enabled = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if SUPPORT_SSL_FALSESTART
|
||||
class SslFastStart {
|
||||
public:
|
||||
SslFastStart() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
SslFastStart(bool enabled) : enabled(enabled) {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool enabled = false;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace ssl
|
||||
|
||||
struct SslOptions {
|
||||
std::string cert_file{};
|
||||
std::string cert_type{};
|
||||
std::string key_file{};
|
||||
std::string key_type{};
|
||||
std::string key_pass{};
|
||||
#if SUPPORT_ALPN
|
||||
bool enable_alpn = true;
|
||||
#endif // SUPPORT_ALPN
|
||||
#if SUPPORT_NPN
|
||||
bool enable_npn = true;
|
||||
#endif // SUPPORT_ALPN
|
||||
bool verify_host = true;
|
||||
bool verify_peer = true;
|
||||
bool verify_status = false;
|
||||
int ssl_version = CURL_SSLVERSION_DEFAULT;
|
||||
#if SUPPORT_MAX_TLS_VERSION
|
||||
int max_version = CURL_SSLVERSION_MAX_DEFAULT;
|
||||
#endif
|
||||
std::string ca_info{};
|
||||
std::string ca_path{};
|
||||
std::string crl_file{};
|
||||
std::string ciphers{};
|
||||
#if SUPPORT_TLSv13_CIPHERS
|
||||
std::string tls13_ciphers{};
|
||||
#endif
|
||||
#if SUPPORT_SESSIONID_CACHE
|
||||
bool session_id_cache = true;
|
||||
#endif
|
||||
|
||||
SslOptions() = default;
|
||||
SslOptions(const SslOptions &) = default;
|
||||
SslOptions(SslOptions &&) noexcept = default;
|
||||
~SslOptions() = default;
|
||||
SslOptions & operator = (const SslOptions &) = default;
|
||||
SslOptions & operator = (SslOptions &&) noexcept = default;
|
||||
|
||||
void SetOption(const ssl::CertFile& opt) {
|
||||
cert_file = opt.filename;
|
||||
cert_type = opt.GetCertType();
|
||||
}
|
||||
void SetOption(const ssl::KeyFile& opt) {
|
||||
key_file = opt.filename;
|
||||
key_type = opt.GetKeyType();
|
||||
key_pass = opt.password;
|
||||
}
|
||||
#if SUPPORT_ALPN
|
||||
void SetOption(const ssl::ALPN& opt) {
|
||||
enable_alpn = opt.enabled;
|
||||
}
|
||||
#endif // SUPPORT_ALPN
|
||||
#if SUPPORT_NPN
|
||||
void SetOption(const ssl::NPN& opt) {
|
||||
enable_npn = opt.enabled;
|
||||
}
|
||||
#endif // SUPPORT_NPN
|
||||
void SetOption(const ssl::VerifyHost& opt) {
|
||||
verify_host = opt.enabled;
|
||||
}
|
||||
void SetOption(const ssl::VerifyPeer& opt) {
|
||||
verify_peer = opt.enabled;
|
||||
}
|
||||
void SetOption(const ssl::VerifyStatus& opt) {
|
||||
verify_status = opt.enabled;
|
||||
}
|
||||
void SetOption(const ssl::TLSv1& /*opt*/) {
|
||||
ssl_version = CURL_SSLVERSION_TLSv1;
|
||||
}
|
||||
#if SUPPORT_SSLv2
|
||||
void SetOption(const ssl::SSLv2& /*opt*/) {
|
||||
ssl_version = CURL_SSLVERSION_SSLv2;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_SSLv3
|
||||
void SetOption(const ssl::SSLv3& /*opt*/) {
|
||||
ssl_version = CURL_SSLVERSION_SSLv3;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_TLSv1_0
|
||||
void SetOption(const ssl::TLSv1_0& /*opt*/) {
|
||||
ssl_version = CURL_SSLVERSION_TLSv1_0;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_TLSv1_1
|
||||
void SetOption(const ssl::TLSv1_1& /*opt*/) {
|
||||
ssl_version = CURL_SSLVERSION_TLSv1_1;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_TLSv1_2
|
||||
void SetOption(const ssl::TLSv1_2& /*opt*/) {
|
||||
ssl_version = CURL_SSLVERSION_TLSv1_2;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_TLSv1_3
|
||||
void SetOption(const ssl::TLSv1_3& /*opt*/) {
|
||||
ssl_version = CURL_SSLVERSION_TLSv1_3;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLS_VERSION
|
||||
void SetOption(const ssl::MaxTLSVersion& /*opt*/) {
|
||||
max_version = CURL_SSLVERSION_DEFAULT;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLSv1_0
|
||||
void SetOption(const ssl::MaxTLSv1_0& opt) {
|
||||
max_version = CURL_SSLVERSION_MAX_TLSv1_0;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLSv1_1
|
||||
void SetOption(const ssl::MaxTLSv1_1& /*opt*/) {
|
||||
max_version = CURL_SSLVERSION_MAX_TLSv1_1;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLSv1_2
|
||||
void SetOption(const ssl::MaxTLSv1_2& /*opt*/) {
|
||||
max_version = CURL_SSLVERSION_MAX_TLSv1_2;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_MAX_TLSv1_3
|
||||
void SetOption(const ssl::MaxTLSv1_3& /*opt*/) {
|
||||
max_version = CURL_SSLVERSION_MAX_TLSv1_3;
|
||||
}
|
||||
#endif
|
||||
void SetOption(const ssl::CaInfo& opt) {
|
||||
ca_info = opt.filename;
|
||||
}
|
||||
void SetOption(const ssl::CaPath& opt) {
|
||||
ca_path = opt.filename;
|
||||
}
|
||||
void SetOption(const ssl::Crl& opt) {
|
||||
crl_file = opt.filename;
|
||||
}
|
||||
void SetOption(const ssl::Ciphers& opt) {
|
||||
ciphers = opt.ciphers;
|
||||
}
|
||||
#if SUPPORT_TLSv13_CIPHERS
|
||||
void SetOption(const ssl::TLS13_Ciphers& opt) {
|
||||
tls13_ciphers = opt.ciphers;
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_SESSIONID_CACHE
|
||||
void SetOption(const ssl::SessionIdCache& opt) {
|
||||
session_id_cache = opt.enabled;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
namespace priv {
|
||||
|
||||
template <typename T>
|
||||
void set_ssl_option(SslOptions& opts, T&& t) {
|
||||
opts.SetOption(std::forward<T>(t));
|
||||
}
|
||||
|
||||
template <typename T, typename... Ts>
|
||||
void set_ssl_option(SslOptions& opts, T&& t, Ts&&... ts) {
|
||||
set_ssl_option(opts, std::forward<T>(t));
|
||||
set_ssl_option(opts, std::move(ts)...);
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
template <typename... Ts>
|
||||
SslOptions Ssl(Ts&&... ts) {
|
||||
SslOptions opts;
|
||||
priv::set_ssl_option(opts, std::move(ts)...);
|
||||
return opts;
|
||||
}
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
100
vendor/CPR/include/cpr/status_codes.h
vendored
100
vendor/CPR/include/cpr/status_codes.h
vendored
@ -1,100 +0,0 @@
|
||||
#ifndef _CPR_STATUS_CODES
|
||||
#define _CPR_STATUS_CODES
|
||||
#include <cstdint>
|
||||
namespace cpr {
|
||||
namespace status {
|
||||
// Information responses
|
||||
constexpr std::int32_t HTTP_CONTINUE = 100;
|
||||
constexpr std::int32_t HTTP_SWITCHING_PROTOCOL = 101;
|
||||
constexpr std::int32_t HTTP_PROCESSING = 102;
|
||||
constexpr std::int32_t HTTP_EARLY_HINTS = 103;
|
||||
// Successful responses
|
||||
constexpr std::int32_t HTTP_OK = 200;
|
||||
constexpr std::int32_t HTTP_CREATED = 201;
|
||||
constexpr std::int32_t HTTP_ACCEPTED = 202;
|
||||
constexpr std::int32_t HTTP_NON_AUTHORITATIVE_INFORMATION = 203;
|
||||
constexpr std::int32_t HTTP_NO_CONTENT = 204;
|
||||
constexpr std::int32_t HTTP_RESET_CONTENT = 205;
|
||||
constexpr std::int32_t HTTP_PARTIAL_CONTENT = 206;
|
||||
constexpr std::int32_t HTTP_MULTI_STATUS = 207;
|
||||
constexpr std::int32_t HTTP_ALREADY_REPORTED = 208;
|
||||
constexpr std::int32_t HTTP_IM_USED = 226;
|
||||
// Redirection messages
|
||||
constexpr std::int32_t HTTP_MULTIPLE_CHOICE = 300;
|
||||
constexpr std::int32_t HTTP_MOVED_PERMANENTLY = 301;
|
||||
constexpr std::int32_t HTTP_FOUND = 302;
|
||||
constexpr std::int32_t HTTP_SEE_OTHER = 303;
|
||||
constexpr std::int32_t HTTP_NOT_MODIFIED = 304;
|
||||
constexpr std::int32_t HTTP_USE_PROXY = 305;
|
||||
constexpr std::int32_t HTTP_UNUSED = 306;
|
||||
constexpr std::int32_t HTTP_TEMPORARY_REDIRECT = 307;
|
||||
constexpr std::int32_t HTTP_PERMANENT_REDIRECT = 308;
|
||||
// Client error responses
|
||||
constexpr std::int32_t HTTP_BAD_REQUEST = 400;
|
||||
constexpr std::int32_t HTTP_UNAUTHORIZED = 401;
|
||||
constexpr std::int32_t HTTP_PAYMENT_REQUIRED = 402;
|
||||
constexpr std::int32_t HTTP_FORBIDDEN = 403;
|
||||
constexpr std::int32_t HTTP_NOT_FOUND = 404;
|
||||
constexpr std::int32_t HTTP_METHOD_NOT_ALLOWED = 405;
|
||||
constexpr std::int32_t HTTP_NOT_ACCEPTABLE = 406;
|
||||
constexpr std::int32_t HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;
|
||||
constexpr std::int32_t HTTP_REQUEST_TIMEOUT = 408;
|
||||
constexpr std::int32_t HTTP_CONFLICT = 409;
|
||||
constexpr std::int32_t HTTP_GONE = 410;
|
||||
constexpr std::int32_t HTTP_LENGTH_REQUIRED = 411;
|
||||
constexpr std::int32_t HTTP_PRECONDITION_FAILED = 412;
|
||||
constexpr std::int32_t HTTP_PAYLOAD_TOO_LARGE = 413;
|
||||
constexpr std::int32_t HTTP_URI_TOO_LONG = 414;
|
||||
constexpr std::int32_t HTTP_UNSUPPORTED_MEDIA_TYPE = 415;
|
||||
constexpr std::int32_t HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
|
||||
constexpr std::int32_t HTTP_EXPECTATION_FAILED = 417;
|
||||
constexpr std::int32_t HTTP_IM_A_TEAPOT = 418;
|
||||
constexpr std::int32_t HTTP_MISDIRECTED_REQUEST = 421;
|
||||
constexpr std::int32_t HTTP_UNPROCESSABLE_ENTITY = 422;
|
||||
constexpr std::int32_t HTTP_LOCKED = 423;
|
||||
constexpr std::int32_t HTTP_FAILED_DEPENDENCY = 424;
|
||||
constexpr std::int32_t HTTP_TOO_EARLY = 425;
|
||||
constexpr std::int32_t HTTP_UPGRADE_REQUIRED = 426;
|
||||
constexpr std::int32_t HTTP_PRECONDITION_REQUIRED = 428;
|
||||
constexpr std::int32_t HTTP_TOO_MANY_REQUESTS = 429;
|
||||
constexpr std::int32_t HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
|
||||
constexpr std::int32_t HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451;
|
||||
// Server response errors
|
||||
constexpr std::int32_t HTTP_INTERNAL_SERVER_ERROR = 500;
|
||||
constexpr std::int32_t HTTP_NOT_IMPLEMENTED = 501;
|
||||
constexpr std::int32_t HTTP_BAD_GATEWAY = 502;
|
||||
constexpr std::int32_t HTTP_SERVICE_UNAVAILABLE = 503;
|
||||
constexpr std::int32_t HTTP_GATEWAY_TIMEOUT = 504;
|
||||
constexpr std::int32_t HTTP_HTTP_VERSION_NOT_SUPPORTED = 505;
|
||||
constexpr std::int32_t HTTP_VARIANT_ALSO_NEGOTIATES = 506;
|
||||
constexpr std::int32_t HTTP_INSUFFICIENT_STORAGE = 507;
|
||||
constexpr std::int32_t HTTP_LOOP_DETECTED = 508;
|
||||
constexpr std::int32_t HTTP_NOT_EXTENDED = 510;
|
||||
constexpr std::int32_t HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511;
|
||||
|
||||
constexpr std::int32_t INFO_CODE_OFFSET = 100;
|
||||
constexpr std::int32_t SUCCESS_CODE_OFFSET = 200;
|
||||
constexpr std::int32_t REDIRECT_CODE_OFFSET = 300;
|
||||
constexpr std::int32_t CLIENT_ERROR_CODE_OFFSET = 400;
|
||||
constexpr std::int32_t SERVER_ERROR_CODE_OFFSET = 500;
|
||||
constexpr std::int32_t MISC_CODE_OFFSET = 600;
|
||||
|
||||
constexpr bool is_informational(const std::int32_t code) {
|
||||
return (code >= INFO_CODE_OFFSET && code < SUCCESS_CODE_OFFSET);
|
||||
}
|
||||
constexpr bool is_success(const std::int32_t code) {
|
||||
return (code >= SUCCESS_CODE_OFFSET && code < REDIRECT_CODE_OFFSET);
|
||||
}
|
||||
constexpr bool is_redirect(const std::int32_t code) {
|
||||
return (code >= REDIRECT_CODE_OFFSET && code < CLIENT_ERROR_CODE_OFFSET);
|
||||
}
|
||||
constexpr bool is_client_error(const std::int32_t code) {
|
||||
return (code >= CLIENT_ERROR_CODE_OFFSET && code < SERVER_ERROR_CODE_OFFSET);
|
||||
}
|
||||
constexpr bool is_server_error(const std::int32_t code) {
|
||||
return (code >= SERVER_ERROR_CODE_OFFSET && code < MISC_CODE_OFFSET);
|
||||
}
|
||||
|
||||
} // namespace status
|
||||
} // namespace cpr
|
||||
#endif
|
25
vendor/CPR/include/cpr/timeout.h
vendored
25
vendor/CPR/include/cpr/timeout.h
vendored
@ -1,25 +0,0 @@
|
||||
#ifndef CPR_TIMEOUT_H
|
||||
#define CPR_TIMEOUT_H
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class Timeout {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Timeout(const std::chrono::milliseconds& duration) : ms{duration} {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Timeout(const std::int32_t& milliseconds) : Timeout{std::chrono::milliseconds(milliseconds)} {}
|
||||
|
||||
// No way around since curl uses a long here.
|
||||
// NOLINTNEXTLINE(google-runtime-int)
|
||||
long Milliseconds() const;
|
||||
|
||||
std::chrono::milliseconds ms;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
21
vendor/CPR/include/cpr/unix_socket.h
vendored
21
vendor/CPR/include/cpr/unix_socket.h
vendored
@ -1,21 +0,0 @@
|
||||
#ifndef CPR_UNIX_SOCKET_H
|
||||
#define CPR_UNIX_SOCKET_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class UnixSocket {
|
||||
public:
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
UnixSocket(std::string&& unix_socket) : unix_socket_(std::move(unix_socket)) {}
|
||||
|
||||
const char* GetUnixSocketString() const noexcept;
|
||||
|
||||
private:
|
||||
const std::string unix_socket_;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
31
vendor/CPR/include/cpr/user_agent.h
vendored
31
vendor/CPR/include/cpr/user_agent.h
vendored
@ -1,31 +0,0 @@
|
||||
#ifndef CPR_USERAGENT_H
|
||||
#define CPR_USERAGENT_H
|
||||
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
|
||||
#include "cpr/cprtypes.h"
|
||||
|
||||
namespace cpr {
|
||||
class UserAgent : public StringHolder<UserAgent> {
|
||||
public:
|
||||
UserAgent() : StringHolder<UserAgent>() {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
UserAgent(const std::string& useragent) : StringHolder<UserAgent>(useragent) {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
UserAgent(std::string&& useragent) : StringHolder<UserAgent>(std::move(useragent)) {}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
UserAgent(const char* useragent) : StringHolder<UserAgent>(useragent) {}
|
||||
UserAgent(const char* str, size_t len) : StringHolder<UserAgent>(str, len) {}
|
||||
UserAgent(const std::initializer_list<std::string> args) : StringHolder<UserAgent>(args) {}
|
||||
UserAgent(const UserAgent& other) = default;
|
||||
UserAgent(UserAgent&& old) noexcept = default;
|
||||
~UserAgent() override = default;
|
||||
|
||||
UserAgent& operator=(UserAgent&& old) noexcept = default;
|
||||
UserAgent& operator=(const UserAgent& other) = default;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
40
vendor/CPR/include/cpr/util.h
vendored
40
vendor/CPR/include/cpr/util.h
vendored
@ -1,40 +0,0 @@
|
||||
#ifndef CPR_UTIL_H
|
||||
#define CPR_UTIL_H
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cpr/callback.h"
|
||||
#include "cpr/cookies.h"
|
||||
#include "cpr/cprtypes.h"
|
||||
#include "cpr/curlholder.h"
|
||||
|
||||
namespace cpr {
|
||||
namespace util {
|
||||
|
||||
Header parseHeader(const std::string& headers, std::string* status_line = nullptr,
|
||||
std::string* reason = nullptr);
|
||||
Cookies parseCookies(curl_slist* raw_cookies);
|
||||
size_t readUserFunction(char* ptr, size_t size, size_t nitems, const ReadCallback* read);
|
||||
size_t headerUserFunction(char* ptr, size_t size, size_t nmemb, const HeaderCallback* header);
|
||||
size_t writeFunction(char* ptr, size_t size, size_t nmemb, std::string* data);
|
||||
size_t writeFileFunction(char* ptr, size_t size, size_t nmemb, std::ofstream* file);
|
||||
size_t writeUserFunction(char* ptr, size_t size, size_t nmemb, const WriteCallback* write);
|
||||
#if LIBCURL_VERSION_NUM < 0x072000
|
||||
int progressUserFunction(const ProgressCallback* progress, double dltotal, double dlnow,
|
||||
double ultotal, double ulnow);
|
||||
#else
|
||||
int progressUserFunction(const ProgressCallback* progress, curl_off_t dltotal, curl_off_t dlnow,
|
||||
curl_off_t ultotal, curl_off_t ulnow);
|
||||
#endif
|
||||
int debugUserFunction(CURL* handle, curl_infotype type, char* data, size_t size,
|
||||
const DebugCallback* debug);
|
||||
std::vector<std::string> split(const std::string& to_split, char delimiter);
|
||||
std::string urlEncode(const std::string& s);
|
||||
std::string urlDecode(const std::string& s);
|
||||
|
||||
} // namespace util
|
||||
} // namespace cpr
|
||||
|
||||
#endif
|
18
vendor/CPR/include/cpr/verbose.h
vendored
18
vendor/CPR/include/cpr/verbose.h
vendored
@ -1,18 +0,0 @@
|
||||
#ifndef CPR_VERBOSE_H_
|
||||
#define CPR_VERBOSE_H_
|
||||
|
||||
namespace cpr {
|
||||
|
||||
class Verbose {
|
||||
public:
|
||||
Verbose() = default;
|
||||
// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
Verbose(const bool verbose) : verbose{verbose} {}
|
||||
|
||||
bool verbose = true;
|
||||
};
|
||||
|
||||
} // namespace cpr
|
||||
|
||||
|
||||
#endif /* CPR_VERBOSE_H_ */
|
Loading…
Reference in New Issue
Block a user