verbose curl logging

This commit is contained in:
a 2024-08-15 22:06:28 +03:00
parent c0bc32849a
commit 50066cc105
3 changed files with 41 additions and 4 deletions

View File

@ -249,7 +249,7 @@ static void run_at_startup()
return;
}
#if defined(STEAM_WIN32)
WSADATA wsaData;
WSADATA wsaData{};
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) {
PRINT_DEBUG("Networking WSAStartup error");
return;
@ -257,8 +257,13 @@ static void run_at_startup()
for (int i = 0; i < 10; ++i) {
//hack: the game Full Mojo Rampage calls WSACleanup on startup so we call WSAStartup a few times so it doesn't get deallocated.
WSAStartup(MAKEWORD(2, 2), &wsaData);
WSADATA wsaData{};
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) {
PRINT_DEBUG("Networking WSAStartup error");
return;
}
}
PRINT_DEBUG("Networking WSAStartup success!");
#else
#endif

View File

@ -160,6 +160,30 @@ bool Steam_HTTP::SetHTTPRequestGetOrPostParameter( HTTPRequestHandle hRequest, c
return true;
}
static int curl_debug_trace(
CURL *handle, curl_infotype type,
char *data, size_t size,
void *clientp
)
{
// https://curl.se/libcurl/c/CURLOPT_DEBUGFUNCTION.html
std::string text{};
switch (type) {
case CURLINFO_TEXT: text = "Info: " + std::string(data, size); break;
case CURLINFO_HEADER_IN: text = "<= Recv header"; break;
case CURLINFO_HEADER_OUT: text = "=> Send header"; break;
case CURLINFO_DATA_IN: text = "<= Recv data"; break;
case CURLINFO_DATA_OUT: text = "=> Send data"; break;
case CURLINFO_SSL_DATA_OUT: text = "=> Send SSL data"; break;
case CURLINFO_SSL_DATA_IN: text = "<= Recv SSL data"; break;
default: text = "[X] ERROR: unknown callback type"; break;
}
PRINT_DEBUG("%s", text.c_str());
return 0;
}
void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t *pCallHandle)
{
@ -213,6 +237,11 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t
send_callresult();
return;
}
#ifndef EMU_RELEASE_BUILD
curl_easy_setopt(chttp, CURLOPT_DEBUGFUNCTION, curl_debug_trace);
curl_easy_setopt(chttp, CURLOPT_VERBOSE, 1L);
#endif
// headers
std::vector<std::string> headers{};
@ -314,7 +343,7 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t
fclose(hfile);
headers.clear();
PRINT_DEBUG("CURL error code for '%s' [%i] (OK == 0)", request->url.c_str(), (int)res_curl);
PRINT_DEBUG("CURL error code for '%s' [%i = '%s'] (OK == 0)", request->url.c_str(), (int)res_curl, curl_easy_strerror(res_curl));
unsigned int file_size = file_size_(request->target_filepath);
if (file_size) {

View File

@ -535,8 +535,9 @@ local wild_zlib_64 = {
if _OPTIONS["build-curl"] or _OPTIONS["all-build"] then
local curl_common_defs = {
"BUILD_CURL_EXE=OFF",
"BUILD_SHARED_LIBS=OFF",
"BUILD_STATIC_CURL=OFF", -- "Build curl executable with static libcurl"
"BUILD_SHARED_LIBS=OFF",
"BUILD_STATIC_LIBS=ON",
"BUILD_MISC_DOCS=OFF",
"BUILD_TESTING=OFF",
@ -544,6 +545,8 @@ if _OPTIONS["build-curl"] or _OPTIONS["all-build"] then
"ENABLE_CURL_MANUAL=OFF",
"CURL_USE_OPENSSL=OFF",
"CURL_ZLIB=ON",
-- fix building on Arch Linux
"CURL_USE_LIBSSH2=OFF",
"CURL_USE_LIBPSL=OFF",
"USE_LIBIDN2=OFF",