From bf7b5e0a81f84d712c393980ad9486624c1ea58e Mon Sep 17 00:00:00 2001 From: Rémy Raes Date: Sun, 21 Jan 2024 00:56:33 +0100 Subject: Add slow-speed timeout when downloading mod (#611) Abort request if network connection is dropped or too slow. --- primedev/mods/autodownload/moddownloader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/primedev/mods/autodownload/moddownloader.cpp b/primedev/mods/autodownload/moddownloader.cpp index 80be8d19..1e3c6af6 100644 --- a/primedev/mods/autodownload/moddownloader.cpp +++ b/primedev/mods/autodownload/moddownloader.cpp @@ -163,6 +163,11 @@ std::optional 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); -- cgit v1.2.3