From 9e4834331add22c39839e0f283dfce7a9bde4001 Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Tue, 4 Jun 2024 21:37:57 +0100 Subject: add read_timeout to net.http.download Stops the connection if the download is 0 and the maximum read_timeout duration has been reached --- xmake/modules/net/http/download.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xmake/modules/net/http/download.lua b/xmake/modules/net/http/download.lua index d622e75d9..b2802d219 100644 --- a/xmake/modules/net/http/download.lua +++ b/xmake/modules/net/http/download.lua @@ -105,6 +105,14 @@ function _curl_download(tool, url, outputfile, opt) table.insert(argv, tostring(opt.timeout)) end + -- set read timeout + if opt.read_timeout then + table.insert(argv, "--speed-limit") + table.insert(argv, "0") + table.insert(argv, "--speed-time") + table.insert(argv, tostring(opt.read_timeout)) + end + -- set url table.insert(argv, url) @@ -181,6 +189,11 @@ function _wget_download(tool, url, outputfile, opt) table.insert(argv, "--timeout=" .. tostring(opt.timeout)) end + -- set read timeout + if opt.read_timeout then + table.insert(argv, "--read-timeout=" .. tostring(opt.read_timeout)) + end + -- set outputfile table.insert(argv, "-O") table.insert(argv, outputfile) -- cgit v1.3.1