Common: Fix logger related crash when HTTP response is empty
This commit is contained in:
parent
fe727ed1d0
commit
72e1131123
|
@ -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);
|
curl_easy_getinfo(m_curl.get(), CURLINFO_RESPONSE_CODE, &response_code);
|
||||||
if (response_code != 200)
|
if (response_code != 200)
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(COMMON, "Failed to {} {}: server replied with code {} and body\n\x1b[0m{:.{}}",
|
if (buffer.empty())
|
||||||
type, url, response_code, buffer.data(), static_cast<int>(buffer.size()));
|
{
|
||||||
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue