diff --git a/src/lceasy.c b/src/lceasy.c index e543675..fe8a463 100644 --- a/src/lceasy.c +++ b/src/lceasy.c @@ -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); diff --git a/src/lcurl.c b/src/lcurl.c index 8ccea5c..ab81a18 100644 --- a/src/lcurl.c +++ b/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); diff --git a/test/test_easy.lua b/test/test_easy.lua index 92d7dcf..6efba8f 100644 --- a/test/test_easy.lua +++ b/test/test_easy.lua @@ -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