http_request: fix http headers not being applied

This commit is contained in:
Syping 2026-03-29 03:34:18 +02:00
parent 60c91d0e4f
commit 58028b6e82

View file

@ -38,7 +38,7 @@ const http_response http_request::get(const std::string &url, const dpp::http_he
header_slist = new_header_slist; header_slist = new_header_slist;
} }
} }
if (!header_slist) if (header_slist)
curl_easy_setopt(instance, CURLOPT_HTTPHEADER, header_slist); curl_easy_setopt(instance, CURLOPT_HTTPHEADER, header_slist);
curl_easy_setopt(instance, CURLOPT_WRITEDATA, &response.content); curl_easy_setopt(instance, CURLOPT_WRITEDATA, &response.content);
curl_easy_setopt(instance, CURLOPT_WRITEFUNCTION, &writer); curl_easy_setopt(instance, CURLOPT_WRITEFUNCTION, &writer);
@ -72,7 +72,7 @@ const http_response http_request::post(const std::string &url, const std::string
header_slist = new_header_slist; header_slist = new_header_slist;
} }
} }
if (!header_slist) if (header_slist)
curl_easy_setopt(instance, CURLOPT_HTTPHEADER, header_slist); curl_easy_setopt(instance, CURLOPT_HTTPHEADER, header_slist);
curl_easy_setopt(instance, CURLOPT_POSTFIELDS, content.data()); curl_easy_setopt(instance, CURLOPT_POSTFIELDS, content.data());
curl_easy_setopt(instance, CURLOPT_POSTFIELDSIZE, content.size()); curl_easy_setopt(instance, CURLOPT_POSTFIELDSIZE, content.size());