summaryrefslogtreecommitdiff
path: root/xmake/modules/net/http/download.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/net/http/download.lua')
-rw-r--r--xmake/modules/net/http/download.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/xmake/modules/net/http/download.lua b/xmake/modules/net/http/download.lua
index 6a292c20e..f85561d49 100644
--- a/xmake/modules/net/http/download.lua
+++ b/xmake/modules/net/http/download.lua
@@ -20,6 +20,7 @@
-- imports
import("core.base.option")
+import("core.base.global")
import("lib.detect.find_tool")
-- get user agent
@@ -62,6 +63,13 @@ function _curl_download(tool, url, outputfile)
table.insert(argv, "-fsSL")
end
+ -- use proxy?
+ local proxy = global.get("proxy")
+ if proxy then
+ table.insert(argv, "-x")
+ table.insert(argv, proxy)
+ end
+
-- set user-agent
local user_agent = _get_user_agent()
if user_agent then
@@ -99,6 +107,23 @@ function _wget_download(tool, url, outputfile)
os.mkdir(outputdir)
end
+ -- use proxy?
+ local proxy = global.get("proxy")
+ if proxy then
+ table.insert(argv, "-e")
+ table.insert(argv, "use_proxy=yes")
+ table.insert(argv, "-e")
+ if url:startswith("http://") then
+ table.insert(argv, "http_proxy=" .. proxy)
+ elseif url:startswith("https://") then
+ table.insert(argv, "https_proxy=" .. proxy)
+ elseif url:startswith("ftp://") then
+ table.insert(argv, "ftp_proxy=" .. proxy)
+ else
+ table.insert(argv, "http_proxy=" .. proxy)
+ end
+ end
+
-- set user-agent
local user_agent = _get_user_agent()
if user_agent then