summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_http.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-02-04 20:29:28 +0100
committerGitHub <noreply@github.com>2022-02-04 20:29:28 +0100
commitafb061c374ed6797f47b0806aba26845713d15ac (patch)
tree52a84a63bfe91ef624654b9f9292077042077bd6 /src/script/lua_api/l_http.cpp
parent1ee37148a8072fe6350124cd51c812c3d3fb069a (diff)
downloadminetest-afb061c374ed6797f47b0806aba26845713d15ac.tar.gz
minetest-afb061c374ed6797f47b0806aba26845713d15ac.tar.bz2
minetest-afb061c374ed6797f47b0806aba26845713d15ac.zip
Fix broken server startup if curl is disabled (#12046)
Diffstat (limited to 'src/script/lua_api/l_http.cpp')
-rw-r--r--src/script/lua_api/l_http.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/script/lua_api/l_http.cpp b/src/script/lua_api/l_http.cpp
index bd359b3cc..5566a8523 100644
--- a/src/script/lua_api/l_http.cpp
+++ b/src/script/lua_api/l_http.cpp
@@ -162,20 +162,6 @@ int ModApiHttp::l_http_fetch_async_get(lua_State *L)
return 1;
}
-int ModApiHttp::l_set_http_api_lua(lua_State *L)
-{
- NO_MAP_LOCK_REQUIRED;
-
- // This is called by builtin to give us a function that will later
- // populate the http_api table with additional method(s).
- // We need this because access to the HTTP api is security-relevant and
- // any mod could just mess with a global variable.
- luaL_checktype(L, 1, LUA_TFUNCTION);
- lua_rawseti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_HTTP_API_LUA);
-
- return 0;
-}
-
int ModApiHttp::l_request_http_api(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
@@ -215,6 +201,22 @@ int ModApiHttp::l_get_http_api(lua_State *L)
#endif
+int ModApiHttp::l_set_http_api_lua(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+
+#if USE_CURL
+ // This is called by builtin to give us a function that will later
+ // populate the http_api table with additional method(s).
+ // We need this because access to the HTTP api is security-relevant and
+ // any mod could just mess with a global variable.
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+ lua_rawseti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_HTTP_API_LUA);
+#endif
+
+ return 0;
+}
+
void ModApiHttp::Initialize(lua_State *L, int top)
{
#if USE_CURL
@@ -231,6 +233,11 @@ void ModApiHttp::Initialize(lua_State *L, int top)
API_FCT(set_http_api_lua);
}
+#else
+
+ // Define this function anyway so builtin can call it without checking
+ API_FCT(set_http_api_lua);
+
#endif
}