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

Function lua_http_get

src/Utils/Config/LuaConfig.cpp:120–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118 }
119
120 static int lua_http_get(lua_State* L) {
121 // http_get(url [, headers]) → body, status_code
122 auto hdrs = LuaHeadersToWstr(L, lua_gettop(L) >= 2 ? 2 : -1);
123 auto r = OSTPlatform::Http::Execute(L"GET", luaL_checkstring(L, 1),
124 nullptr, 0, hdrs.empty() ? nullptr : hdrs.c_str());
125 if (r.ok) {
126 lua_pushstring(L, r.body.c_str());
127 lua_pushinteger(L, r.status);
128 } else {
129 lua_pushnil(L);
130 lua_pushstring(L, "HTTP request failed");
131 }
132 return 2;
133 }
134
135 static int lua_http_post(lua_State* L) {
136 // http_post(url, post_body [, headers]) → body, status_code

Callers

nothing calls this directly

Calls 3

LuaHeadersToWstrFunction · 0.85
ExecuteFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected