lua-users home
lua-l archive

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

2017-04-20 15:07 GMT+02:00 Alexey Melnichuk <>:

>>>> c:setopt_writefunction(function(chunk)
>>>>   i = i + 1
>>>>   if (#chunk > 4096) then print(i, #chunk) end
>>>>   f:write(chunk)
>>>> end)

> Did you try code that I post.

Thanks, my eyes have finally opened. 16384 is the block size in
which lcurl serves up the chunks. It is the responsibility of
'writefunction' to reassemble them. That is why one must
provide a write function. If lcurl assembled them, it could just
return a string.

My writefunction consisted of simply storing the string in a variable.

Now I ask you, was I just being dense, or is the documentation
not very forthcoming?

easy:setopt_writefunction (writer[, context]) Set writer function.

A callback accepting one or two parameters. The first is the writer
context if any, and the second is a string with the data to be
written. Function must return `true` (any non number true value) or
full data length or nothing to continue operation. Otherwise the
transfer will be aborted with an error.


writer function
context writer context