lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Michal Kottman wrote:
> - luacurl http://luaforge.net/projects/luacurl/
> - Lua-cURL http://luaforge.net/projects/lua-curl/

It's confusing, isn't it, like with lua-curl news appearing
on the LuaCURL page, and the lua-curl package also being named
freepops-luacurl (note no hyphen between lua and curl), and its
debian package name being liblua5.1-curl0, and lua-curl also
existing capitalised as Lua-cURL, and being owned by Jürgen
on the lua-curl page but by Enrico on the luacurl page...
I hope I got that mostly right... Anyway, enough of that.

> I ended up with the following code in my utility module
> http://github.com/mkottman/wdm

They sure increased the size of that Download button :-)

Very useful, thank you!
(other interesting stuff, too - I'll have to check it all out.)

Regards,  Peter Billam

P.S. FWIW, my wget (still untested with the non-freepops) is now:

  function wget(url)
    local text = {}
    local function WriteMemoryCallback(a,b)
        -- luacurl and Lua-cURL friendly, see http://github.com/mkottman/wdm
        local s ; if type(a) == "string" then s = a else s = b end
        text[#text+1] = s
        return string.len(s)
    end
    local c
    if curl.new then c = curl.new() else c = curl.easy_init() end
    c:setopt(curl.OPT_URL, url)
    c:setopt(curl.OPT_WRITEFUNCTION, WriteMemoryCallback)
    c:setopt(curl.OPT_USERAGENT, "luacurl-agent/1.0")
    assert(c:perform())
    if curl.close then c:close() end
    return table.concat(text,'')
  end

http://www.pjb.com.au       pj@pjb.com.au      (03) 6278 9410
"Was der Meister nicht kann,   vermöcht es der Knabe, hätt er
 ihm immer gehorcht?"   Siegfried to Mime, from Act 1 Scene 2