MCPcopy Create free account
hub / github.com/OpenSteam001/OpenSteamTool / lua_http_post

Function lua_http_post

src/Utils/Config/LuaConfig.cpp:135–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 }
134
135 static int lua_http_post(lua_State* L) {
136 // http_post(url, post_body [, headers]) → body, status_code
137 size_t bodyLen = 0;
138 const char* body = luaL_checklstring(L, 2, &bodyLen);
139 auto hdrs = LuaHeadersToWstr(L, lua_gettop(L) >= 3 ? 3 : -1);
140 auto r = OSTPlatform::Http::Execute(L"POST", luaL_checkstring(L, 1),
141 body, static_cast<uint32_t>(bodyLen),
142 hdrs.empty() ? nullptr : hdrs.c_str());
143 if (r.ok) {
144 lua_pushstring(L, r.body.c_str());
145 lua_pushinteger(L, r.status);
146 } else {
147 lua_pushnil(L);
148 lua_pushstring(L, "HTTP request failed");
149 }
150 return 2;
151 }
152
153 // ── Case-insensitive global function lookup ─────────────────
154 // __index metamethod on _G: when a global name isn't found,

Callers

nothing calls this directly

Calls 3

LuaHeadersToWstrFunction · 0.85
ExecuteFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected