aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_bosh.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-08-06 01:57:20 +0100
committerMatthew Wild <mwild1@gmail.com>2010-08-06 01:57:20 +0100
commit2f31218aa44c4a3a9a6ff0c5f9849bf5190ccc53 (patch)
tree2bd68328d09e4ffa3192ac42a94c7cd63f1898c7 /plugins/mod_bosh.lua
parent9b5ea721c474c488cffe9e7a303f9cc9bd4b6171 (diff)
downloadprosody-2f31218aa44c4a3a9a6ff0c5f9849bf5190ccc53.tar.gz
prosody-2f31218aa44c4a3a9a6ff0c5f9849bf5190ccc53.zip
mod_bosh: Add error callback for xmlhandlers, to handle the case of invalid or unusable XML in the request payload
Diffstat (limited to 'plugins/mod_bosh.lua')
-rw-r--r--plugins/mod_bosh.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua
index 7b655489..88095f3c 100644
--- a/plugins/mod_bosh.lua
+++ b/plugins/mod_bosh.lua
@@ -293,6 +293,21 @@ function stream_callbacks.handlestanza(request, stanza)
end
end
+function stream_callbacks.error(request, error)
+ log("debug", "Error parsing BOSH request payload; %s", error);
+ if not request.sid then
+ request:send({ headers = default_headers, status = "400 Bad Request" });
+ return;
+ end
+
+ local session = sessions[request.sid];
+ if error == "stream-error" then -- Remote stream error, we close normally
+ session:close();
+ else
+ session:close({ condition = "bad-format", text = "Error processing stream" });
+ end
+end
+
local dead_sessions = {};
function on_timer()
-- log("debug", "Checking for requests soon to timeout...");