summaryrefslogtreecommitdiff
path: root/Source/Core/Common/HttpRequest.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-10-29 22:07:24 +0100
committerGitHub <noreply@github.com>2020-10-29 22:07:24 +0100
commitf665ddae51a2c3f0deee90d708061a4467c02850 (patch)
treed24e92941c30e3d214ef1aef72449ef0a9290b7b /Source/Core/Common/HttpRequest.cpp
parent650638c069852a1a20b438c740a079295ff46e87 (diff)
parent72e1131123a1900815b9984396a720eae20fe9f0 (diff)
Merge pull request #9202 from WamWooWam/patch-http-requests
Fix logger related crash when HTTP response is empty.
Diffstat (limited to 'Source/Core/Common/HttpRequest.cpp')
-rw-r--r--Source/Core/Common/HttpRequest.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/Source/Core/Common/HttpRequest.cpp b/Source/Core/Common/HttpRequest.cpp
index 1cbf2aebc4..a60b33abbd 100644
--- a/Source/Core/Common/HttpRequest.cpp
+++ b/Source/Core/Common/HttpRequest.cpp
@@ -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 {};
}