mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-31 00:32:53 +00:00
Merge pull request #8210 from spycrab/httpreq_error_msg
Common/HttpRequest: Use CURLOPT_ERRORBUFFER for error messages
This commit is contained in:
commit
84b9b37fef
@ -42,6 +42,7 @@ private:
|
|||||||
static inline std::once_flag s_curl_was_initialized;
|
static inline std::once_flag s_curl_was_initialized;
|
||||||
ProgressCallback m_callback;
|
ProgressCallback m_callback;
|
||||||
std::unique_ptr<CURL, decltype(&curl_easy_cleanup)> m_curl{nullptr, curl_easy_cleanup};
|
std::unique_ptr<CURL, decltype(&curl_easy_cleanup)> m_curl{nullptr, curl_easy_cleanup};
|
||||||
|
std::string m_error_string;
|
||||||
};
|
};
|
||||||
|
|
||||||
HttpRequest::HttpRequest(std::chrono::milliseconds timeout_ms, ProgressCallback callback)
|
HttpRequest::HttpRequest(std::chrono::milliseconds timeout_ms, ProgressCallback callback)
|
||||||
@ -119,6 +120,10 @@ HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback c
|
|||||||
curl_easy_setopt(m_curl.get(), CURLOPT_PROGRESSFUNCTION, CurlProgressCallback);
|
curl_easy_setopt(m_curl.get(), CURLOPT_PROGRESSFUNCTION, CurlProgressCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up error buffer
|
||||||
|
m_error_string.resize(CURL_ERROR_SIZE);
|
||||||
|
curl_easy_setopt(m_curl.get(), CURLOPT_ERRORBUFFER, m_error_string.data());
|
||||||
|
|
||||||
// libcurl may not have been built with async DNS support, so we disable
|
// libcurl may not have been built with async DNS support, so we disable
|
||||||
// signal handlers to avoid a possible and likely crash if a resolve times out.
|
// signal handlers to avoid a possible and likely crash if a resolve times out.
|
||||||
curl_easy_setopt(m_curl.get(), CURLOPT_NOSIGNAL, true);
|
curl_easy_setopt(m_curl.get(), CURLOPT_NOSIGNAL, true);
|
||||||
@ -205,7 +210,7 @@ HttpRequest::Response HttpRequest::Impl::Fetch(const std::string& url, Method me
|
|||||||
const CURLcode res = curl_easy_perform(m_curl.get());
|
const CURLcode res = curl_easy_perform(m_curl.get());
|
||||||
if (res != CURLE_OK)
|
if (res != CURLE_OK)
|
||||||
{
|
{
|
||||||
ERROR_LOG(COMMON, "Failed to %s %s: %s", type, url.c_str(), curl_easy_strerror(res));
|
ERROR_LOG(COMMON, "Failed to %s %s: %s", type, url.c_str(), m_error_string.c_str());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user