From b6cfc996eb570cdcab1ca4d4c3e80c851aef7d1e Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 9 Sep 2010 16:01:11 -0300 Subject: Remove LuaCurl now that we have download() implemented with LuaSocket --- src/luarocks/fs/lua.lua | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index f3d75b44..cd0a31e0 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -14,7 +14,6 @@ local _, ftp = pcall(require, "socket.ftp") local zip_ok, lrzip = pcall(require, "luarocks.tools.zip") local unzip_ok, luazip = pcall(require, "zip"); _G.zip = nil local lfs_ok, lfs = pcall(require, "lfs") ---local curl_ok, curl = pcall(require, "luacurl") local md5_ok, md5 = pcall(require, "md5") local posix_ok, posix = pcall(require, "posix") @@ -449,47 +448,6 @@ end end ---------------------------------------------------------------------- --- LuaCurl functions ---------------------------------------------------------------------- - -if curl_ok then - ---- Download a remote file. --- @param url string: URL to be fetched. --- @param filename string or nil: this function attempts to detect the --- resulting local filename of the remote file as the basename of the URL; --- if that is not correct (due to a redirection, for example), the local --- filename can be given explicitly as this second argument. --- @return boolean: true on success, false on failure. -function download(url, filename) - assert(type(url) == "string") - assert(type(filename) == "string" or not filename) - - filename = dir.path(fs.current_dir(), filename or dir.base_name(url)) - - local c = curl.new() - if not c then return false end - local file = io.open(filename, "wb") - if not file then return false end - local ok = c:setopt(curl.OPT_WRITEFUNCTION, function (stream, buffer) - stream:write(buffer) - return string.len(buffer) - end) - ok = ok and c:setopt(curl.OPT_WRITEDATA, file) - ok = ok and c:setopt(curl.OPT_BUFFERSIZE, 5000) - ok = ok and c:setopt(curl.OPT_HTTPHEADER, "Connection: Keep-Alive") - ok = ok and c:setopt(curl.OPT_URL, url) - ok = ok and c:setopt(curl.OPT_CONNECTTIMEOUT, 15) - ok = ok and c:setopt(curl.OPT_USERAGENT, cfg.user_agent) - ok = ok and c:perform() - ok = ok and c:close() - file:close() - return ok -end - -end - --------------------------------------------------------------------- -- LuaSocket functions --------------------------------------------------------------------- -- cgit v1.2.3-55-g6feb