Check http response code
This commit is contained in:
parent
fde0f341dd
commit
0fc70945a6
@ -174,7 +174,15 @@ namespace download
|
|||||||
const auto& result = data.value();
|
const auto& result = data.value();
|
||||||
if (result.code != CURLE_OK)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,11 +83,14 @@ namespace utils::http
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto code = curl_easy_perform(curl);
|
const auto code = curl_easy_perform(curl);
|
||||||
|
unsigned int response_code{};
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
|
||||||
|
|
||||||
if (code == CURLE_OK)
|
if (code == CURLE_OK)
|
||||||
{
|
{
|
||||||
result result;
|
result result;
|
||||||
result.code = code;
|
result.code = code;
|
||||||
|
result.response_code = response_code;
|
||||||
result.buffer = std::move(buffer);
|
result.buffer = std::move(buffer);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -12,6 +12,7 @@ namespace utils::http
|
|||||||
struct result
|
struct result
|
||||||
{
|
{
|
||||||
CURLcode code{};
|
CURLcode code{};
|
||||||
|
unsigned int response_code{};
|
||||||
std::string buffer{};
|
std::string buffer{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user