From 7645ca38368994bd3aec760df275f4ad890d6cbb Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 2 Mar 2021 15:17:55 +1000 Subject: [PATCH] HTTPDownloader: Log error code for WinHttpOpen() failure --- src/frontend-common/http_downloader_winhttp.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/frontend-common/http_downloader_winhttp.cpp b/src/frontend-common/http_downloader_winhttp.cpp index 7f49bc26c..ea6a4bb32 100644 --- a/src/frontend-common/http_downloader_winhttp.cpp +++ b/src/frontend-common/http_downloader_winhttp.cpp @@ -35,11 +35,20 @@ bool HTTPDownloaderWinHttp::Initialize() m_hSession = WinHttpOpen(StringUtil::UTF8StringToWideString(m_user_agent).c_str(), WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, nullptr, nullptr, WINHTTP_FLAG_ASYNC); if (m_hSession == NULL) + { + Log_ErrorPrintf("WinHttpOpen() failed: %u", GetLastError()); return false; + } const DWORD notification_flags = WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_FLAG_REQUEST_ERROR | WINHTTP_CALLBACK_FLAG_HANDLES | WINHTTP_CALLBACK_FLAG_SECURE_FAILURE; - WinHttpSetStatusCallback(m_hSession, HTTPStatusCallback, notification_flags, NULL); + if (WinHttpSetStatusCallback(m_hSession, HTTPStatusCallback, notification_flags, NULL) == + WINHTTP_INVALID_STATUS_CALLBACK) + { + Log_ErrorPrint("WinHttpSetStatusCallback() failed: %u", GetLastError()); + return false; + } + return true; }