diff --git a/src/lcmulti.c b/src/lcmulti.c index 4bfc1e7..2ba0f63 100644 --- a/src/lcmulti.c +++ b/src/lcmulti.c @@ -424,11 +424,17 @@ static int lcurl_opt_set_string_array_(lua_State *L, int opt){ lcurl_multi_t *p = lcurl_getmulti(L); CURLMcode code; int n; - luaL_argcheck(L, lua_type(L, 2) == LUA_TTABLE, 2, "array expected"); - n = lua_rawlen(L, 2); + + if (lutil_is_null(L, 2)) { + n = 0; + } + else { + luaL_argcheck(L, lua_type(L, 2) == LUA_TTABLE, 2, "array expected"); + n = lua_rawlen(L, 2); + } + if(n == 0){ - char *val[] = {NULL}; - code = curl_multi_setopt(p->curl, opt, val); + code = curl_multi_setopt(p->curl, opt, 0); } else{ int i; diff --git a/test/test_easy.lua b/test/test_easy.lua index 1f1e12f..3195b61 100644 --- a/test/test_easy.lua +++ b/test/test_easy.lua @@ -1064,11 +1064,12 @@ end local _ENV = TEST_CASE'set_null' if ENABLE then -local c +local c, m function teardown() if c then c:close() end - c = nil + if m then m:close() end + m, c = nil end function test_string() @@ -1109,6 +1110,14 @@ function test_slist_via_table() assert_not_match("X%-Custom:%s*value\r\n", headers) end +function test_multi_set_array() + m = curl.multi() + m:setopt_pipelining_site_bl{ + '127.0.0.1' + } + assert_equal(m, m:setopt_pipelining_site_bl(null)) +end + end RUN()