mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-20 19:45:22 +02:00
Enforce minimum for curl(_file_download)_timeout
This commit is contained in:
@@ -416,8 +416,8 @@ void ClientMediaDownloader::startRemoteMediaTransfers()
|
||||
fetch_request.url = url;
|
||||
fetch_request.caller = m_httpfetch_caller;
|
||||
fetch_request.request_id = m_httpfetch_next_id;
|
||||
fetch_request.timeout =
|
||||
g_settings->getS32("curl_file_download_timeout");
|
||||
fetch_request.timeout = std::max(MIN_HTTPFETCH_TIMEOUT,
|
||||
(long)g_settings->getS32("curl_file_download_timeout"));
|
||||
httpfetch_async(fetch_request);
|
||||
|
||||
m_remote_file_transfers.insert(std::make_pair(
|
||||
|
@@ -574,7 +574,8 @@ bool GUIEngine::downloadFile(const std::string &url, const std::string &target)
|
||||
HTTPFetchResult fetch_result;
|
||||
fetch_request.url = url;
|
||||
fetch_request.caller = HTTPFETCH_SYNC;
|
||||
fetch_request.timeout = g_settings->getS32("curl_file_download_timeout");
|
||||
fetch_request.timeout = std::max(MIN_HTTPFETCH_TIMEOUT,
|
||||
(long)g_settings->getS32("curl_file_download_timeout"));
|
||||
httpfetch_sync(fetch_request, fetch_result);
|
||||
|
||||
if (!fetch_result.succeeded) {
|
||||
|
@@ -47,6 +47,7 @@ HTTPFetchRequest::HTTPFetchRequest() :
|
||||
connect_timeout(10 * 1000),
|
||||
useragent(std::string(PROJECT_NAME_C "/") + g_version_hash + " (" + porting::get_sysinfo() + ")")
|
||||
{
|
||||
timeout = std::max(timeout, MIN_HTTPFETCH_TIMEOUT_INTERACTIVE);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -35,6 +35,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// Start of regular allocated caller IDs.
|
||||
#define HTTPFETCH_CID_START 3
|
||||
|
||||
namespace {
|
||||
// lower bound for curl_timeout (see also settingtypes.txt)
|
||||
constexpr long MIN_HTTPFETCH_TIMEOUT_INTERACTIVE = 1000;
|
||||
// lower bound for curl_file_download_timeout
|
||||
constexpr long MIN_HTTPFETCH_TIMEOUT = 5000;
|
||||
}
|
||||
|
||||
// Methods
|
||||
enum HttpMethod : u8
|
||||
{
|
||||
|
Reference in New Issue
Block a user