Check http response code
This commit is contained in:
parent
b5a26eb82f
commit
9397a8dda4
@ -174,7 +174,15 @@ namespace download
|
||||
const auto& result = data.value();
|
||||
if (result.code != CURLE_OK)
|
||||
{
|
||||
menu_error(utils::string::va("Download failed: %s (%i)\n", curl_easy_strerror(result.code), result.code));
|
||||
menu_error(utils::string::va("Download failed: %s (%i)\n",
|
||||
curl_easy_strerror(result.code), result.code));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.response_code >= 400)
|
||||
{
|
||||
menu_error(utils::string::va("Download failed: Server returned bad response code %i\n",
|
||||
result.response_code));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,11 +83,14 @@ namespace utils::http
|
||||
}
|
||||
|
||||
const auto code = curl_easy_perform(curl);
|
||||
unsigned int response_code{};
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
|
||||
|
||||
if (code == CURLE_OK)
|
||||
{
|
||||
result result;
|
||||
result.code = code;
|
||||
result.response_code = response_code;
|
||||
result.buffer = std::move(buffer);
|
||||
|
||||
return result;
|
||||
|
@ -12,6 +12,7 @@ namespace utils::http
|
||||
struct result
|
||||
{
|
||||
CURLcode code{};
|
||||
unsigned int response_code{};
|
||||
std::string buffer{};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user