# HG changeset patch # User Matthew Wild # Date 1281056240 -3600 # Node ID cc2dc55e66f99aaf0697a71c57103a6d7849d052 # Parent 9c0b3cd890e996f5df2c7987866596baa5865ba2 mod_bosh: Add error callback for xmlhandlers, to handle the case of invalid or unusable XML in the request payload diff -r 9c0b3cd890e9 -r cc2dc55e66f9 plugins/mod_bosh.lua --- a/plugins/mod_bosh.lua Tue Aug 03 21:37:06 2010 +0500 +++ b/plugins/mod_bosh.lua Fri Aug 06 01:57:20 2010 +0100 @@ -293,6 +293,21 @@ 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...");