Add header support to http action

This commit is contained in:
WarmUpTill
2023-02-23 01:02:12 +01:00
committed by WarmUpTill
parent c8722c9f62
commit dcf9816a72
5 changed files with 93 additions and 12 deletions

View File

@@ -32,6 +32,14 @@ Curlhelper::~Curlhelper()
}
}
curl_slist *Curlhelper::SlistAppend(curl_slist *list, const char *string)
{
if (!_initialized) {
return nullptr;
}
return _slistAppend(list, string);
}
CURLcode Curlhelper::Perform()
{
if (!_initialized) {
@@ -88,10 +96,11 @@ bool Curlhelper::Resolve()
{
_init = (initFunction)_lib->resolve("curl_easy_init");
_setopt = (setOptFunction)_lib->resolve("curl_easy_setopt");
_slistAppend = (slistAppendFunction)_lib->resolve("curl_slist_append");
_perform = (performFunction)_lib->resolve("curl_easy_perform");
_cleanup = (cleanupFunction)_lib->resolve("curl_easy_cleanup");
if (_init && _setopt && _perform && _cleanup) {
if (_init && _setopt && _slistAppend && _perform && _cleanup) {
blog(LOG_INFO, "[adv-ss] curl loaded successfully");
return true;
}

View File

@@ -5,6 +5,8 @@
typedef CURL *(*initFunction)(void);
typedef void (*cleanupFunction)(CURL *);
typedef CURLcode (*setOptFunction)(CURL *, CURLoption, ...);
typedef struct curl_slist *(*slistAppendFunction)(struct curl_slist *list,
const char *string);
typedef CURLcode (*performFunction)(CURL *);
class Curlhelper {
@@ -13,6 +15,8 @@ public:
~Curlhelper();
template<typename... Args> CURLcode SetOpt(CURLoption, Args...);
struct curl_slist *SlistAppend(struct curl_slist *list,
const char *string);
CURLcode Perform();
bool Initialized() { return _initialized; }
@@ -22,6 +26,7 @@ private:
initFunction _init = nullptr;
setOptFunction _setopt = nullptr;
slistAppendFunction _slistAppend = nullptr;
performFunction _perform = nullptr;
cleanupFunction _cleanup = nullptr;
CURL *_curl = nullptr;