Fix. Cleanup slists references in the reset function
This commit is contained in:
parent
29d8667cc2
commit
b80dab0f12
@ -292,6 +292,10 @@ static int lcurl_easy_reset(lua_State *L){
|
||||
lua_settop(L, 1);
|
||||
|
||||
if(p->storage != LUA_NOREF){
|
||||
int i;
|
||||
for (i = 0; i < LCURL_LIST_COUNT; ++i) {
|
||||
p->lists[i] = LUA_NOREF;
|
||||
}
|
||||
lcurl_storage_free(L, p->storage);
|
||||
p->storage = lcurl_storage_init(L);
|
||||
lua_settop(L, 1);
|
||||
|
34
src/lcurl.c
34
src/lcurl.c
@ -25,6 +25,18 @@
|
||||
# define LCURL_EXPORT_API LUALIB_API
|
||||
#endif
|
||||
|
||||
static const char* LCURL_REGISTRY = "LCURL Registry";
|
||||
static const char* LCURL_USERVAL = "LCURL Uservalues";
|
||||
#if LCURL_CURL_VER_GE(7,56,0)
|
||||
static const char* LCURL_MIME_EASY_MAP = "LCURL Mime easy";
|
||||
#endif
|
||||
|
||||
#if LCURL_CURL_VER_GE(7,56,0)
|
||||
#define NUP 3
|
||||
#else
|
||||
#define NUP 2
|
||||
#endif
|
||||
|
||||
static int lcurl_easy_new_safe(lua_State *L){
|
||||
return lcurl_easy_create(L, LCURL_ERROR_RETURN);
|
||||
}
|
||||
@ -78,6 +90,11 @@ static int lcurl_version(lua_State *L){
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lcurl_debug_getregistry(lua_State *L) {
|
||||
lua_rawgetp(L, LUA_REGISTRYINDEX, LCURL_REGISTRY);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int push_upper(lua_State *L, const char *str){
|
||||
char buffer[128];
|
||||
size_t i, n = strlen(str);
|
||||
@ -192,7 +209,9 @@ static const struct luaL_Reg lcurl_functions[] = {
|
||||
#endif
|
||||
{"version", lcurl_version },
|
||||
{"version_info", lcurl_version_info },
|
||||
|
||||
|
||||
{"__getregistry", lcurl_debug_getregistry},
|
||||
|
||||
{NULL,NULL}
|
||||
};
|
||||
|
||||
@ -208,6 +227,8 @@ static const struct luaL_Reg lcurl_functions_safe[] = {
|
||||
{"version", lcurl_version },
|
||||
{"version_info", lcurl_version_info },
|
||||
|
||||
{ "__getregistry", lcurl_debug_getregistry },
|
||||
|
||||
{NULL,NULL}
|
||||
};
|
||||
|
||||
@ -222,17 +243,6 @@ static const lcurl_const_t lcurl_flags[] = {
|
||||
|
||||
static volatile int LCURL_INIT = 0;
|
||||
|
||||
static const char* LCURL_REGISTRY = "LCURL Registry";
|
||||
static const char* LCURL_USERVAL = "LCURL Uservalues";
|
||||
#if LCURL_CURL_VER_GE(7,56,0)
|
||||
static const char* LCURL_MIME_EASY_MAP = "LCURL Mime easy";
|
||||
#endif
|
||||
|
||||
#if LCURL_CURL_VER_GE(7,56,0)
|
||||
#define NUP 3
|
||||
#else
|
||||
#define NUP 2
|
||||
#endif
|
||||
|
||||
#if LCURL_CURL_VER_GE(7,56,0)
|
||||
#define LCURL_PUSH_NUP(L) lua_pushvalue(L, -NUP-1);lua_pushvalue(L, -NUP-1);lua_pushvalue(L, -NUP-1);
|
||||
|
@ -1103,6 +1103,23 @@ function test_set_empty_array()
|
||||
assert_not_match("X%-Custom:%s*value\r\n", headers)
|
||||
end
|
||||
|
||||
function test_reset_slist()
|
||||
c = curl.easy {
|
||||
httpheader = {'X-Foo: 1'},
|
||||
resolve = {'example.com:80:127.0.0.1'}
|
||||
}
|
||||
|
||||
c:reset()
|
||||
|
||||
c:setopt{
|
||||
httpheader = {'X-Foo: 2'},
|
||||
resolve = {'example.com:80:127.0.0.1'}
|
||||
}
|
||||
|
||||
local body, headers = assert_string(dump_request(c))
|
||||
assert_match("X%-Foo:%s2\r\n", headers)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local _ENV = TEST_CASE'set_null' if ENABLE then
|
||||
|
Loading…
x
Reference in New Issue
Block a user