Update examples.
parent
810ab53ffd
commit
9d27c9404d
|
@ -8,7 +8,7 @@ local function printf(...)
|
|||
io.stderr:write(string.format(...))
|
||||
end
|
||||
|
||||
local function dumb(title, data, n)
|
||||
local function dump(title, data, n)
|
||||
n = n or 16
|
||||
printf("%s, %10.10d bytes (0x%8.8x)\n", title, #data, #data)
|
||||
for i = 1, #data do
|
||||
|
@ -28,7 +28,7 @@ local function my_trace(type, data)
|
|||
if type == curl.INFO_HEADER_IN then text = "<= Recv header" end
|
||||
if type == curl.INFO_DATA_IN then text = "<= Recv data" end
|
||||
if type == curl.INFO_SSL_DATA_IN then text = "<= Recv SSL data" end
|
||||
if text then dumb(text, data) end
|
||||
if text then dump(text, data) end
|
||||
end
|
||||
|
||||
local easy = curl.easy{
|
||||
|
|
|
@ -21,7 +21,7 @@ local c = curl.easy{
|
|||
}
|
||||
|
||||
local data, n = 0, 0
|
||||
c:setopt_writefunction(function(chunk) data = #chunk + 1 end)
|
||||
c:setopt_writefunction(function(chunk) data = #chunk + data end)
|
||||
|
||||
-- called before each new file
|
||||
c:setopt_chunk_bgn_function(function(info, remains)
|
||||
|
@ -32,7 +32,7 @@ end)
|
|||
|
||||
-- called after file download complite
|
||||
c:setopt_chunk_end_function(function()
|
||||
printf('total size %d\n', data)
|
||||
printf('total size %d[B]\n', data)
|
||||
printf('------------------------------------------------------\n')
|
||||
end)
|
||||
|
||||
|
|
Loading…
Reference in New Issue