lua-users home
lua-l archive

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


LuaCURL is CURL 7.14.0 binding to Lua 5.x
Home Page: http://luacurl.luaforge.net
Download: http://luaforge.net/projects/luacurl/

Here is an example how it works:

require("luacurl")

c=curl.new()

c:setopt(curl.OPT_WRITEFUNCTION, function (stream, buffer)
	if stream:write(buffer) then
		return string.len(buffer);
	end
end);

c:setopt(curl.OPT_WRITEDATA, io.open("lua-5.0.2.tar.gz", "wb"));

c:setopt(curl.OPT_PROGRESSFUNCTION, function (_, dltotal, dlnow, uptotal, upnow)
	print(dltotal, dlnow, uptotal, upnow);
end);

c:setopt(curl.OPT_NOPROGRESS, false);

c:setopt(curl.OPT_HTTPHEADER, "Connection: Keep-Alive", "Accept-Language: en-us");

c:setopt(curl.OPT_URL, "http://www.lua.org/ftp/lua-5.0.2.tar.gz";);
c:setopt(curl.OPT_CONNECTTIMEOUT, 15);
c:perform();
c:close();

Please send me feedback with suggestions how to improve it, bug reports etc.

Best Regards,
alek


_____________________________________________________________
Get your free email at http://www.crazyland.com