diff mod_rest/mod_rest.lua @ 3799:a1f1f703d604

mod_rest: Allow collection of original stanza after sending HTTP request Probably a premature optimization, but there should be no need to keep the full original stanza after this point.
author Kim Alvefur <zash@zash.se>
date Mon, 30 Dec 2019 05:19:23 +0100
parents 9b4fd2553365
children d59fb4dcf100
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua	Mon Dec 30 05:18:52 2019 +0100
+++ b/mod_rest/mod_rest.lua	Mon Dec 30 05:19:23 2019 +0100
@@ -127,8 +127,13 @@
 			receipt = st.stanza("received", { xmlns = "urn:xmpp:receipts", id = stanza.id });
 		end
 
+		local request_body = tostring(stanza);
+
+		-- Keep only the top level element and let the rest be GC'd
+		stanza = st.clone(stanza, true);
+
 		http.request(rest_url, {
-				body = tostring(stanza),
+				body = request_body,
 				headers = {
 					["Content-Type"] = "application/xmpp+xml",
 					["Content-Language"] = stanza.attr["xml:lang"],