summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChi Huu Huynh <[email protected]>2024-06-04 21:37:57 +0100
committerChi Huu Huynh <[email protected]>2024-06-04 21:37:57 +0100
commit9e4834331add22c39839e0f283dfce7a9bde4001 (patch)
treeb5ab96a66f9d78670fca841fc15932825c8fa7cb
parent38ae0ac6591f098f7ed47a69b9ec01e6723575ed (diff)
add read_timeout to net.http.download
Stops the connection if the download is 0 and the maximum read_timeout duration has been reached
-rw-r--r--xmake/modules/net/http/download.lua13
1 files changed, 13 insertions, 0 deletions
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)