diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.lua index 6f7e26b1e..52600e7a3 100644 --- a/resources/prosody-plugins/util.lib.lua +++ b/resources/prosody-plugins/util.lib.lua @@ -62,15 +62,17 @@ end function wrap_async_run(event,handler) - local result; + -- Grab a local response so that we can send the http response when + -- the handler is done. + local response = event.response; local async_func = runner(function (event) - local wait, done = waiter(); - result=handler(event); - done(); - return result; + response.status_code = handler(event); + -- Send the response to the waiting http client. + response:send(); end) async_func:run(event) - return result; + -- return true to keep the client http connection open. + return true; end --- Updates presence stanza, by adding identity node @@ -136,4 +138,4 @@ return { wrap_async_run = wrap_async_run; room_jid_match_rewrite = room_jid_match_rewrite; update_presence_identity = update_presence_identity; -}; \ No newline at end of file +};