Change. Unset httppost options with stream also unset readfunction.

This commit is contained in:
Alexey Melnichuk 2014-09-03 11:33:00 +05:00
parent db7e541e09
commit 2da7106ebb
2 changed files with 15 additions and 8 deletions

View File

@ -393,10 +393,19 @@ static int lcurl_easy_unset_HTTPPOST(lua_State *L){
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code); return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
} }
lcurl_storage_get_i(L, p->storage, CURLOPT_HTTPPOST);
if(!lua_isnil(L, -1)){
lcurl_hpost_t *form = lcurl_gethpost_at(L, -1);
if(form->stream){
/* with stream we do not set CURLOPT_READDATA but
we also unset it to be sure that there no way to
call default curl reader with our READDATA
*/
curl_easy_setopt(p->curl, CURLOPT_READFUNCTION, 0);
curl_easy_setopt(p->curl, CURLOPT_READDATA, 0);
}
lcurl_storage_remove_i(L, p->storage, CURLOPT_HTTPPOST); lcurl_storage_remove_i(L, p->storage, CURLOPT_HTTPPOST);
}
//! @fixme unset readdata/readfunction for
// curl_easy_setopt(p->curl, CURLOPT_READFUNCTION, 0);
lua_settop(L, 1); lua_settop(L, 1);
return 1; return 1;

View File

@ -62,12 +62,10 @@ void lcurl_storage_get_i(lua_State *L, int storage, int i){
lua_rawgeti(L, LCURL_LUA_REGISTRY, storage); lua_rawgeti(L, LCURL_LUA_REGISTRY, storage);
lua_rawgeti(L, -1, LCURL_STORAGE_KV); lua_rawgeti(L, -1, LCURL_STORAGE_KV);
if(lua_istable(L, -1)){ if(lua_istable(L, -1)){
lua_rawgeti(L, -2, i); lua_rawgeti(L, -1, i);
lua_remove(L, -2);
lua_remove(L, -2); lua_remove(L, -2);
} }
else lua_remove(L, -2);
lua_pop(L, 2);
} }
struct curl_slist* lcurl_storage_remove_slist(lua_State *L, int storage, int idx){ struct curl_slist* lcurl_storage_remove_slist(lua_State *L, int storage, int idx){