Add. getinfo
method
This commit is contained in:
parent
70af182080
commit
9d36abc5d6
@ -134,13 +134,28 @@ function easy:close() end
|
|||||||
--- Set options.
|
--- Set options.
|
||||||
--
|
--
|
||||||
-- @tparam number opt one of `curl.OPT_XXX` constant
|
-- @tparam number opt one of `curl.OPT_XXX` constant
|
||||||
-- @params ... value
|
-- @param ... value
|
||||||
|
-- @treturn easy self
|
||||||
--
|
--
|
||||||
-- @usage
|
-- @usage
|
||||||
-- c:setopt(curl.OPT_URL, "http://example.com")
|
-- c:setopt(curl.OPT_URL, "http://example.com")
|
||||||
-- c:setopt(curl.OPT_READFUNCTION, function(t, n) return table.remove(t) end, {"1111", "2222"})
|
-- c:setopt(curl.OPT_READFUNCTION,
|
||||||
|
-- function(t, n) return table.remove(t) end,
|
||||||
|
-- {"1111", "2222"}
|
||||||
|
-- )
|
||||||
function easy:setopt() end
|
function easy:setopt() end
|
||||||
|
|
||||||
|
--- Get information.
|
||||||
|
--
|
||||||
|
-- @tparam number info one of `curl.INFO_XXX` constant
|
||||||
|
-- @return value
|
||||||
|
--
|
||||||
|
-- @usage
|
||||||
|
-- print(c:getinfo(curl.INFO_EFFECTIVE_URL))
|
||||||
|
-- print(c:getinfo(curl.INFO_TOTAL_TIME))
|
||||||
|
-- print(c:getinfo(curl.INFO_RESPONSE_CODE))
|
||||||
|
function easy:getinfo() end
|
||||||
|
|
||||||
--- Set writer function.
|
--- Set writer function.
|
||||||
--
|
--
|
||||||
-- A callback accepting one or two parameters.
|
-- A callback accepting one or two parameters.
|
||||||
|
15
src/lceasy.c
15
src/lceasy.c
@ -650,6 +650,20 @@ static int lcurl_easy_setopt(lua_State *L){
|
|||||||
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, CURLE_UNKNOWN_OPTION);
|
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, CURLE_UNKNOWN_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lcurl_easy_getinfo(lua_State *L){
|
||||||
|
lcurl_easy_t *p = lcurl_geteasy(L);
|
||||||
|
int opt = luaL_checklong(L, 2);
|
||||||
|
lua_remove(L, 2);
|
||||||
|
|
||||||
|
#define OPT_ENTRY(l, N, T, S) case CURLINFO_##N: return lcurl_easy_get_##N(L);
|
||||||
|
switch(opt){
|
||||||
|
#include "lcinfoeasy.h"
|
||||||
|
}
|
||||||
|
#undef OPT_ENTRY
|
||||||
|
|
||||||
|
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, CURLE_UNKNOWN_OPTION);
|
||||||
|
}
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
static const struct luaL_Reg lcurl_easy_methods[] = {
|
static const struct luaL_Reg lcurl_easy_methods[] = {
|
||||||
@ -669,6 +683,7 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
|
|||||||
#undef OPT_ENTRY
|
#undef OPT_ENTRY
|
||||||
|
|
||||||
{ "setopt", lcurl_easy_setopt },
|
{ "setopt", lcurl_easy_setopt },
|
||||||
|
{ "getinfo", lcurl_easy_getinfo },
|
||||||
{ "escape", lcurl_easy_escape },
|
{ "escape", lcurl_easy_escape },
|
||||||
{ "unescape", lcurl_easy_unescape },
|
{ "unescape", lcurl_easy_unescape },
|
||||||
{ "perform", lcurl_easy_perform },
|
{ "perform", lcurl_easy_perform },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user