fix(vim.net): always pass response body to on_response #38460

Problem:
on_response(err, response) handler doesn't receive a response when an
output buffer or path is supplied to vim.net.request. User might want to
both output output to a file/buffer and also do something with it on
response.

Solution:
If an on_response handler was given, then pass the response to it.
This commit is contained in:
Yochem van Rosmalen
2026-03-24 12:30:00 +01:00
committed by GitHub
parent ebc9811149
commit 10ca09a2cb

View File

@@ -86,7 +86,7 @@ function M.request(url, opts, on_response)
elseif res.code ~= 0 then
err = res.stderr ~= '' and res.stderr or ('Request failed with exit code %d'):format(res.code)
else
if not (opts.outpath or opts.outbuf) then
if on_response then
response = {
body = res.stdout --[[@as string]],
}