From ad8eab3d66031e6c21b502a0fc6aecd7e0941476 Mon Sep 17 00:00:00 2001 From: Tixx <83774803+WiserTixx@users.noreply.github.com> Date: Sun, 29 Dec 2024 16:39:56 +0100 Subject: [PATCH] Log error buffer --- src/Network/Http.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Network/Http.cpp b/src/Network/Http.cpp index eef2143..734fe44 100644 --- a/src/Network/Http.cpp +++ b/src/Network/Http.cpp @@ -73,14 +73,18 @@ std::string HTTP::Get(const std::string& IP) { static thread_local CURL* curl = curl_easy_init(); if (curl) { CURLcode res; + char errbuf[CURL_ERROR_SIZE]; curl_easy_setopt(curl, CURLOPT_URL, IP.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&Ret); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); // seconds curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); + errbuf[0] = 0; res = curl_easy_perform(curl); if (res != CURLE_OK) { error("GET to " + IP + " failed: " + std::string(curl_easy_strerror(res))); + error("Curl error: " + std::string(errbuf)); return ""; } } else { @@ -95,6 +99,7 @@ std::string HTTP::Post(const std::string& IP, const std::string& Fields) { static thread_local CURL* curl = curl_easy_init(); if (curl) { CURLcode res; + char errbuf[CURL_ERROR_SIZE]; curl_easy_setopt(curl, CURLOPT_URL, IP.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&Ret); @@ -106,10 +111,13 @@ std::string HTTP::Post(const std::string& IP, const std::string& Fields) { curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); // seconds curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); + errbuf[0] = 0; res = curl_easy_perform(curl); curl_slist_free_all(list); if (res != CURLE_OK) { error("POST to " + IP + " failed: " + std::string(curl_easy_strerror(res))); + error("Curl error: " + std::string(errbuf)); return ""; } } else {