Skip to content

Commit b56a028

Browse files
committedMay 17, 2021
Fix curl_timeout being ignored for Lua HTTP fetches
1 parent d44f1aa commit b56a028

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
 

‎src/script/lua_api/l_http.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ void ModApiHttp::read_http_fetch_request(lua_State *L, HTTPFetchRequest &req)
4242

4343
req.caller = httpfetch_caller_alloc_secure();
4444
getstringfield(L, 1, "url", req.url);
45-
lua_getfield(L, 1, "user_agent");
46-
if (lua_isstring(L, -1))
47-
req.useragent = getstringfield_default(L, 1, "user_agent", "");
48-
lua_pop(L, 1);
45+
getstringfield(L, 1, "user_agent", req.useragent);
4946
req.multipart = getboolfield_default(L, 1, "multipart", false);
50-
req.timeout = getintfield_default(L, 1, "timeout", 3) * 1000;
47+
if (getintfield(L, 1, "timeout", req.timeout))
48+
req.timeout *= 1000;
5149

5250
lua_getfield(L, 1, "method");
5351
if (lua_isstring(L, -1)) {

0 commit comments

Comments
 (0)
Please sign in to comment.