Fix. Set callback with context.
Update Documentation
This commit is contained in:
parent
76ea5d49f1
commit
70af182080
@ -110,6 +110,37 @@ end
|
||||
--
|
||||
do
|
||||
|
||||
--- Perform a file transfer
|
||||
--
|
||||
-- @return[1] self
|
||||
function easy:perfom() end
|
||||
|
||||
--- URL encodes the given string
|
||||
--
|
||||
-- @tparam string url
|
||||
-- @return[1] encoded url
|
||||
function easy:escape() end
|
||||
|
||||
--- URL decodes the given string
|
||||
--
|
||||
-- @tparam string url
|
||||
-- @return[1] decoded url
|
||||
function easy:unescape() end
|
||||
|
||||
--- End easy session
|
||||
--
|
||||
function easy:close() end
|
||||
|
||||
--- Set options.
|
||||
--
|
||||
-- @tparam number opt one of `curl.OPT_XXX` constant
|
||||
-- @params ... value
|
||||
--
|
||||
-- @usage
|
||||
-- c:setopt(curl.OPT_URL, "http://example.com")
|
||||
-- c:setopt(curl.OPT_READFUNCTION, function(t, n) return table.remove(t) end, {"1111", "2222"})
|
||||
function easy:setopt() end
|
||||
|
||||
--- Set writer function.
|
||||
--
|
||||
-- A callback accepting one or two parameters.
|
||||
@ -159,7 +190,7 @@ function easy:setopt_headerfunction() end
|
||||
-- A callback accepting one or two parameters.
|
||||
-- The first is the reader context if any, and the second is the maximum amount of data to be read.
|
||||
-- You can ignore second argument and pass as mach data as you need. lcurl can split data.
|
||||
-- Function must return data to continue operation. To stop operation it must return empty string.
|
||||
-- Function must return data to continue operation. To stop operation it must return empty string on nil.
|
||||
-- Otherwise the transfer will be aborted with an error.
|
||||
--
|
||||
-- @tparam function reader
|
||||
@ -216,25 +247,4 @@ function easy:setopt_httppost() end
|
||||
-- @return[1] self
|
||||
function easy:setopt_postfields() end
|
||||
|
||||
--- Perform a file transfer
|
||||
--
|
||||
-- @return[1] self
|
||||
function easy:perfom() end
|
||||
|
||||
--- URL encodes the given string
|
||||
--
|
||||
-- @tparam string url
|
||||
-- @return[1] encoded url
|
||||
function easy:escape() end
|
||||
|
||||
--- URL decodes the given string
|
||||
--
|
||||
-- @tparam string url
|
||||
-- @return[1] decoded url
|
||||
function easy:unescape() end
|
||||
|
||||
--- End easy session
|
||||
--
|
||||
function easy:close() end
|
||||
|
||||
end
|
||||
|
@ -384,6 +384,10 @@ static int lcurl_easy_set_callback(lua_State *L,
|
||||
luaL_argcheck(L, !lua_isnil(L, 2), 2, "no function present");
|
||||
c->ud_ref = luaL_ref(L, LCURL_LUA_REGISTRY);
|
||||
c->cb_ref = luaL_ref(L, LCURL_LUA_REGISTRY);
|
||||
|
||||
curl_easy_setopt(p->curl, OPT_UD, p);
|
||||
curl_easy_setopt(p->curl, OPT_CB, func);
|
||||
|
||||
assert(1 == lua_gettop(L));
|
||||
return 1;
|
||||
}
|
||||
@ -511,7 +515,10 @@ static int lcurl_read_callback(char *buffer, size_t size, size_t nitems, void *a
|
||||
lua_pushnumber(L, ret);
|
||||
if(lua_pcall(L, n, LUA_MULTRET, 0)) return CURL_READFUNC_ABORT;
|
||||
|
||||
if(lua_isnoneornil(L, top + 1)) return CURL_READFUNC_ABORT;
|
||||
if(lua_isnoneornil(L, top + 1)){
|
||||
if(lua_gettop(L) <= (top + 1))return 0;
|
||||
return CURL_READFUNC_ABORT;
|
||||
}
|
||||
data = lua_tolstring(L, -1, &data_size);
|
||||
if(!data) return CURL_READFUNC_ABORT;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user