diff options
Diffstat (limited to 'builtin/game')
-rw-r--r-- | builtin/game/misc.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index bacadf18f..d0e67bd88 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -178,3 +178,22 @@ function core.raillike_group(name) end return id end + +-- HTTP callback interface +function core.http_add_fetch(httpenv) + httpenv.fetch = function(req, callback) + local handle = httpenv.fetch_async(req) + + local function update_http_status() + local res = httpenv.fetch_async_get(handle) + if res.completed then + callback(res) + else + core.after(0, update_http_status) + end + end + core.after(0, update_http_status) + end + + return httpenv +end |