demo.lua

changeset 1
7ef4b95f77b5
child 2
38f221e53215
equal deleted inserted replaced
0:6e60da4625db 1:7ef4b95f77b5
1 require "lahttp"
2 require "multihttp"
3
4 local function mycallback(url, status, data)
5 print("---------------");
6 if status == 200 then -- HTTP OK
7 print("Received the data from "..url..":");
8 print(data)
9 else
10 print("Received HTTP error "..status.." while downloading from "..url);
11 end
12 print("---------------");
13 end
14
15 local function progresscallback(batch)
16 for url,progress in pairs(batch:progress()) do
17 print(url..":");
18 for statistic, value in pairs(progress) do
19 print("", k..": "..v);
20 end
21 end
22 print("");
23 end
24
25 batch_download = multihttp.new(mycallback, { "http://www.google.com/", "http://example.com/" });
26
27 batch_download:set_progress_callback(progresscallback);
28
29 batch_download:download(true); -- true means "don't return until all downloads are finished"

mercurial