Add slow-speed timeout when downloading mod (#611)

Abort request if network connection is dropped or too slow.
This commit is contained in:
Rémy Raes 2024-01-21 00:56:33 +01:00 committed by GitHub
parent c7edf9bf74
commit bf7b5e0a81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -163,6 +163,11 @@ std::optional<fs::path> ModDownloader::FetchModFromDistantStore(std::string_view
curl_easy_setopt(easyhandle, CURLOPT_URL, url.data());
curl_easy_setopt(easyhandle, CURLOPT_FAILONERROR, 1L);
// abort if slower than 30 bytes/sec during 10 seconds
curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_LIMIT, 30L);
curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, WriteData);
curl_easy_setopt(easyhandle, CURLOPT_NOPROGRESS, 0L);