| 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 |
nothing calls this directly
no test coverage detected