mod_bosh: Return errors when appropriate (invalid XML, missing sid)
authorMatthew Wild <mwild1@gmail.com>
Wed, 05 Jun 2013 21:39:56 +0100
changeset 5647 8767b47524c9
parent 5646 c4b6ebea7185
child 5648 f7f667c48d9a
mod_bosh: Return errors when appropriate (invalid XML, missing sid)
plugins/mod_bosh.lua
--- a/plugins/mod_bosh.lua	Wed Jun 05 21:37:33 2013 +0100
+++ b/plugins/mod_bosh.lua	Wed Jun 05 21:39:56 2013 +0100
@@ -123,7 +123,10 @@
 	-- In particular, the streamopened() stream callback is where
 	-- much of the session logic happens, because it's where we first
 	-- get to see the 'sid' of this request.
-	stream:feed(body);
+	if not stream:feed(body) then
+		module:log("warn", "Error parsing BOSH payload")
+		return 400;
+	end
 	
 	-- Stanzas (if any) in the request have now been processed, and
 	-- we take care of the high-level BOSH logic here, including
@@ -174,6 +177,8 @@
 			return true; -- Inform http server we shall reply later
 		end
 	end
+	module:log("warn", "Unable to associate request with a session (incomplete request?)");
+	return 400;
 end