p2pool: fix crash without network connection

This commit is contained in:
selsta 2023-04-09 18:26:03 +02:00
parent 6ac8e7a464
commit 33310786db
No known key found for this signature in database
GPG key ID: 2EA0A99A8B07AE5E

View file

@ -68,10 +68,10 @@ void P2PoolManager::download() {
std::chrono::milliseconds timeout = std::chrono::seconds(10); std::chrono::milliseconds timeout = std::chrono::seconds(10);
http_client.set_server(url.host().toStdString(), "443", {}); http_client.set_server(url.host().toStdString(), "443", {});
bool success = http_client.invoke_get(url.path().toStdString(), timeout, {}, std::addressof(response), {{"User-Agent", userAgent}}); bool success = http_client.invoke_get(url.path().toStdString(), timeout, {}, std::addressof(response), {{"User-Agent", userAgent}});
if (response->m_response_code == 404) { if (success && response->m_response_code == 404) {
emit p2poolDownloadFailure(BinaryNotAvailable); emit p2poolDownloadFailure(BinaryNotAvailable);
return; return;
} else if (response->m_response_code == 302) { } else if (success && response->m_response_code == 302) {
epee::net_utils::http::fields_list fields = response->m_header_info.m_etc_fields; epee::net_utils::http::fields_list fields = response->m_header_info.m_etc_fields;
for (std::pair<std::string, std::string> i : fields) { for (std::pair<std::string, std::string> i : fields) {
if (i.first == "Location") { if (i.first == "Location") {