aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/mason-core/fetch.lua31
-rw-r--r--lua/mason/health.lua2
2 files changed, 25 insertions, 8 deletions
diff --git a/lua/mason-core/fetch.lua b/lua/mason-core/fetch.lua
index c1f01dc2..be79db1f 100644
--- a/lua/mason-core/fetch.lua
+++ b/lua/mason-core/fetch.lua
@@ -75,19 +75,36 @@ local function fetch(url, opts)
end
local function wget()
- local headers =
- _.sort_by(_.identity, _.map(_.compose(_.format "--header=%s", _.join ": "), _.to_pairs(opts.headers)))
+ local headers = _.sort_by(
+ _.nth(2),
+ _.map(
+ _.compose(function(header)
+ return { "--header", header }
+ end, _.join ": "),
+ _.to_pairs(opts.headers)
+ )
+ )
+
+ if opts.data and opts.method ~= "POST" then
+ return Result.failure(("fetch: data provided but method is not POST (was %s)"):format(opts.method or "-"))
+ end
+
+ if not _.any(_.equals(opts.method), { "GET", "POST" }) then
+ -- Note: --spider can be used for HEAD support, if ever needed
+ return Result.failure(("fetch: wget doesn't support HTTP method %s"):format(opts.method))
+ end
+
return spawn.wget {
headers,
- "-nv",
"-o",
"/dev/null",
"-O",
opts.out_file or "-",
- ("--timeout=%s"):format(TIMEOUT_SECONDS),
- ("--method=%s"):format(opts.method),
- opts.data and {
- ("--body-data=%s"):format(opts.data) or vim.NIL,
+ "-T",
+ TIMEOUT_SECONDS,
+ opts.data and opts.method == "POST" and {
+ "--post-data",
+ opts.data,
} or vim.NIL,
url,
}
diff --git a/lua/mason/health.lua b/lua/mason/health.lua
index fcef1832..b105940d 100644
--- a/lua/mason/health.lua
+++ b/lua/mason/health.lua
@@ -94,7 +94,7 @@ local function check_core_utils()
check { name = "unzip", cmd = "unzip", args = { "-v" }, relaxed = true }
-- wget is used interchangeably with curl, but with lower priority, so we mark wget as relaxed
- check { cmd = "wget", args = { "--version" }, name = "wget", relaxed = true }
+ check { cmd = "wget", args = { "--help" }, name = "wget", relaxed = true }
check { cmd = "curl", args = { "--version" }, name = "curl" }
check {
cmd = "gzip",