]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix curl_timeout being ignored for Lua HTTP fetches
authorsfan5 <sfan5@live.de>
Sun, 16 May 2021 12:05:43 +0000 (14:05 +0200)
committersfan5 <sfan5@live.de>
Mon, 17 May 2021 15:12:30 +0000 (17:12 +0200)
src/script/lua_api/l_http.cpp

index 5ea3b3f996f0143ea4300f111166825a3ae0b12a..751ec98376a3dfaf12b9e333ad64003342ed0d0c 100644 (file)
@@ -42,12 +42,10 @@ void ModApiHttp::read_http_fetch_request(lua_State *L, HTTPFetchRequest &req)
 
        req.caller = httpfetch_caller_alloc_secure();
        getstringfield(L, 1, "url", req.url);
-       lua_getfield(L, 1, "user_agent");
-       if (lua_isstring(L, -1))
-               req.useragent = getstringfield_default(L, 1, "user_agent", "");
-       lua_pop(L, 1);
+       getstringfield(L, 1, "user_agent", req.useragent);
        req.multipart = getboolfield_default(L, 1, "multipart", false);
-       req.timeout = getintfield_default(L, 1, "timeout", 3) * 1000;
+       if (getintfield(L, 1, "timeout", req.timeout))
+               req.timeout *= 1000;
 
        lua_getfield(L, 1, "method");
        if (lua_isstring(L, -1)) {