# HG changeset patch # User Matthew Wild # Date 1262411856 0 # Node ID 7ef4b95f77b5404b782e7e0d0cac9bbbc7329a0c # Parent 6e60da4625db83c203b06b471f3fda896e7e9b57 Add demo.lua to demonstrate usage diff -r 6e60da4625db -r 7ef4b95f77b5 demo.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo.lua Sat Jan 02 05:57:36 2010 +0000 @@ -0,0 +1,29 @@ +require "lahttp" +require "multihttp" + +local function mycallback(url, status, data) + print("---------------"); + if status == 200 then -- HTTP OK + print("Received the data from "..url..":"); + print(data) + else + print("Received HTTP error "..status.." while downloading from "..url); + end + print("---------------"); +end + +local function progresscallback(batch) + for url,progress in pairs(batch:progress()) do + print(url..":"); + for statistic, value in pairs(progress) do + print("", k..": "..v); + end + end + print(""); +end + +batch_download = multihttp.new(mycallback, { "http://www.google.com/", "http://example.com/" }); + +batch_download:set_progress_callback(progresscallback); + +batch_download:download(true); -- true means "don't return until all downloads are finished"