Merge pull request #9202 from WamWooWam/patch-http-requests

Fix logger related crash when HTTP response is empty.
This commit is contained in:
Léo Lam 2020-10-29 22:07:24 +01:00 committed by GitHub
commit f665ddae51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -221,8 +221,16 @@ HttpRequest::Response HttpRequest::Impl::Fetch(const std::string& url, Method me
curl_easy_getinfo(m_curl.get(), CURLINFO_RESPONSE_CODE, &response_code);
if (response_code != 200)
{
ERROR_LOG_FMT(COMMON, "Failed to {} {}: server replied with code {} and body\n\x1b[0m{:.{}}",
type, url, response_code, buffer.data(), static_cast<int>(buffer.size()));
if (buffer.empty())
{
ERROR_LOG_FMT(COMMON, "Failed to {} {}: server replied with code {}", type, url,
response_code);
}
else
{
ERROR_LOG_FMT(COMMON, "Failed to {} {}: server replied with code {} and body\n\x1b[0m{:.{}}",
type, url, response_code, buffer.data(), static_cast<int>(buffer.size()));
}
return {};
}