diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2010-09-09 16:01:11 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2010-09-09 16:01:11 -0300 |
| commit | b6cfc996eb570cdcab1ca4d4c3e80c851aef7d1e (patch) | |
| tree | b07a46678aab6811fac7f8c4a3141be9b424c7fa /src | |
| parent | 455818ca4ce650a31a27de7f2a57c04293c2ffe8 (diff) | |
| download | luarocks-b6cfc996eb570cdcab1ca4d4c3e80c851aef7d1e.tar.gz luarocks-b6cfc996eb570cdcab1ca4d4c3e80c851aef7d1e.tar.bz2 luarocks-b6cfc996eb570cdcab1ca4d4c3e80c851aef7d1e.zip | |
Remove LuaCurl now that we have download() implemented with LuaSocket
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/lua.lua | 42 |
1 files changed, 0 insertions, 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") | |||
| 14 | local zip_ok, lrzip = pcall(require, "luarocks.tools.zip") | 14 | local zip_ok, lrzip = pcall(require, "luarocks.tools.zip") |
| 15 | local unzip_ok, luazip = pcall(require, "zip"); _G.zip = nil | 15 | local unzip_ok, luazip = pcall(require, "zip"); _G.zip = nil |
| 16 | local lfs_ok, lfs = pcall(require, "lfs") | 16 | local lfs_ok, lfs = pcall(require, "lfs") |
| 17 | --local curl_ok, curl = pcall(require, "luacurl") | ||
| 18 | local md5_ok, md5 = pcall(require, "md5") | 17 | local md5_ok, md5 = pcall(require, "md5") |
| 19 | local posix_ok, posix = pcall(require, "posix") | 18 | local posix_ok, posix = pcall(require, "posix") |
| 20 | 19 | ||
| @@ -450,47 +449,6 @@ end | |||
| 450 | end | 449 | end |
| 451 | 450 | ||
| 452 | --------------------------------------------------------------------- | 451 | --------------------------------------------------------------------- |
| 453 | -- LuaCurl functions | ||
| 454 | --------------------------------------------------------------------- | ||
| 455 | |||
| 456 | if curl_ok then | ||
| 457 | |||
| 458 | --- Download a remote file. | ||
| 459 | -- @param url string: URL to be fetched. | ||
| 460 | -- @param filename string or nil: this function attempts to detect the | ||
| 461 | -- resulting local filename of the remote file as the basename of the URL; | ||
| 462 | -- if that is not correct (due to a redirection, for example), the local | ||
| 463 | -- filename can be given explicitly as this second argument. | ||
| 464 | -- @return boolean: true on success, false on failure. | ||
| 465 | function download(url, filename) | ||
| 466 | assert(type(url) == "string") | ||
| 467 | assert(type(filename) == "string" or not filename) | ||
| 468 | |||
| 469 | filename = dir.path(fs.current_dir(), filename or dir.base_name(url)) | ||
| 470 | |||
| 471 | local c = curl.new() | ||
| 472 | if not c then return false end | ||
| 473 | local file = io.open(filename, "wb") | ||
| 474 | if not file then return false end | ||
| 475 | local ok = c:setopt(curl.OPT_WRITEFUNCTION, function (stream, buffer) | ||
| 476 | stream:write(buffer) | ||
| 477 | return string.len(buffer) | ||
| 478 | end) | ||
| 479 | ok = ok and c:setopt(curl.OPT_WRITEDATA, file) | ||
| 480 | ok = ok and c:setopt(curl.OPT_BUFFERSIZE, 5000) | ||
| 481 | ok = ok and c:setopt(curl.OPT_HTTPHEADER, "Connection: Keep-Alive") | ||
| 482 | ok = ok and c:setopt(curl.OPT_URL, url) | ||
| 483 | ok = ok and c:setopt(curl.OPT_CONNECTTIMEOUT, 15) | ||
| 484 | ok = ok and c:setopt(curl.OPT_USERAGENT, cfg.user_agent) | ||
| 485 | ok = ok and c:perform() | ||
| 486 | ok = ok and c:close() | ||
| 487 | file:close() | ||
| 488 | return ok | ||
| 489 | end | ||
| 490 | |||
| 491 | end | ||
| 492 | |||
| 493 | --------------------------------------------------------------------- | ||
| 494 | -- LuaSocket functions | 452 | -- LuaSocket functions |
| 495 | --------------------------------------------------------------------- | 453 | --------------------------------------------------------------------- |
| 496 | 454 | ||
