Mercurial > prosody-modules
changeset 5332:e0b5468aae49
mod_rest: Allow passing configuring a timeout for <iq> responses
The default 2 minutes is not how long you want to wait, sometimes.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 07 Apr 2023 20:26:33 +0200 |
parents | e00e3e2c72a3 |
children | 10fcfa7e62a1 |
files | mod_rest/mod_rest.lua |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua Fri Apr 07 15:21:54 2023 +0100 +++ b/mod_rest/mod_rest.lua Fri Apr 07 20:26:33 2023 +0200 @@ -390,7 +390,10 @@ module:hook(archive_event_name, archive_handler, 1); end - local p = module:send_iq(payload, origin):next( + local iq_timeout = tonumber(request.headers.prosody_rest_timeout) or module:get_option_number("rest_iq_timeout", 60*2); + iq_timeout = math.min(iq_timeout, module:get_option_boolean("rest_iq_max_timeout", 300)); + + local p = module:send_iq(payload, origin, iq_timeout):next( function (result) module:log("debug", "Sending[rest]: %s", result.stanza:top_tag()); response.headers.content_type = send_type;