libs/core: Added target parameter to luci.sys.httpget
This commit is contained in:
parent
df40e4df5e
commit
3a09a73d2b
1 changed files with 9 additions and 3 deletions
|
@ -106,10 +106,16 @@ end
|
||||||
--- Returns the contents of a documented referred by an URL.
|
--- Returns the contents of a documented referred by an URL.
|
||||||
-- @param url The URL to retrieve
|
-- @param url The URL to retrieve
|
||||||
-- @param stream Return a stream instead of a buffer
|
-- @param stream Return a stream instead of a buffer
|
||||||
|
-- @param target Directly write to target file name
|
||||||
-- @return String containing the contents of given the URL
|
-- @return String containing the contents of given the URL
|
||||||
function httpget(url, stream)
|
function httpget(url, stream, target)
|
||||||
|
if not target then
|
||||||
local source = stream and io.open or luci.util.exec
|
local source = stream and io.open or luci.util.exec
|
||||||
return source("wget -qO- '"..url:gsub("'", "").."'")
|
return source("wget -qO- '"..url:gsub("'", "").."'")
|
||||||
|
else
|
||||||
|
return os.execute("wget -qO '%s' '%s'" %
|
||||||
|
{target:gsub("'", ""), url:gsub("'", "")})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the system load average values.
|
--- Returns the system load average values.
|
||||||
|
|
Loading…
Reference in a new issue