From b56a028d6bc101cb01f5bdfe07053ac1af9fb016 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 16 May 2021 14:05:43 +0200 Subject: Fix curl_timeout being ignored for Lua HTTP fetches --- src/script/lua_api/l_http.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_http.cpp b/src/script/lua_api/l_http.cpp index 5ea3b3f99..751ec9837 100644 --- a/src/script/lua_api/l_http.cpp +++ b/src/script/lua_api/l_http.cpp @@ -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)) { -- cgit v1.2.3