From 2f31218aa44c4a3a9a6ff0c5f9849bf5190ccc53 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 6 Aug 2010 01:57:20 +0100 Subject: mod_bosh: Add error callback for xmlhandlers, to handle the case of invalid or unusable XML in the request payload --- plugins/mod_bosh.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'plugins') 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..."); -- cgit v1.2.3