summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-26 18:02:27 +0000
committerSteven Barth <steven@midlink.org>2008-08-26 18:02:27 +0000
commit3a09a73d2bf54d63e0b281d029b074da832a4f88 (patch)
treec9474b37d68f8cb5f278bd167779a6512d6cacc9
parentdf40e4df5e3485d1d70548b420e02b81aa61e60b (diff)
libs/core: Added target parameter to luci.sys.httpget
-rw-r--r--libs/sys/luasrc/sys.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua
index bce4e8a62c..557a7ce54c 100644
--- a/libs/sys/luasrc/sys.lua
+++ b/libs/sys/luasrc/sys.lua
@@ -106,10 +106,16 @@ end
--- Returns the contents of a documented referred by an URL.
-- @param url The URL to retrieve
-- @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
-function httpget(url, stream)
- local source = stream and io.open or luci.util.exec
- return source("wget -qO- '"..url:gsub("'", "").."'")
+function httpget(url, stream, target)
+ if not target then
+ local source = stream and io.open or luci.util.exec
+ return source("wget -qO- '"..url:gsub("'", "").."'")
+ else
+ return os.execute("wget -qO '%s' '%s'" %
+ {target:gsub("'", ""), url:gsub("'", "")})
+ end
end
--- Returns the system load average values.