mod_bosh: Add error callback for xmlhandlers, to handle the case of invalid or unusab...
authorMatthew Wild <mwild1@gmail.com>
Fri, 6 Aug 2010 00:57:20 +0000 (01:57 +0100)
committerMatthew Wild <mwild1@gmail.com>
Fri, 6 Aug 2010 00:57:20 +0000 (01:57 +0100)
plugins/mod_bosh.lua

index 7b655489e9f0bb03d025b2d6b3f483ac45044f64..88095f3c72ea14e1604220b4bd32b8b12c5bb0e7 100644 (file)
@@ -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...");