Changeset

2886:3baee526d714

mod_compression: Return <setup-failed/> instead of <unsupported-method/> where applicable.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 09 Mar 2010 20:14:47 +0500
parents 2885:ae72c0dd6f1f
children 2887:765e7070d0a8 2889:c1e6df7cf56a 2890:6273d4672cb4
files plugins/mod_compression.lua
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_compression.lua	Tue Mar 09 18:19:50 2010 +0500
+++ b/plugins/mod_compression.lua	Tue Mar 09 20:14:47 2010 +0500
@@ -40,7 +40,7 @@
 		function(session, stanza)
 			-- fail if we are already compressed
 			if session.compressed then
-				local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("unsupported-method");
+				local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed");
 				session.send(error_st);
 				session.log("warn", "Tried to establish another compression layer.");
 				return;
@@ -48,7 +48,7 @@
 			
 			-- checking if the compression method is supported
 			local method = stanza:child_with_name("method");
-			method = method and method[1];
+			method = method and (method[1] or "");
 			if method == "zlib" then
 				-- create deflate and inflate streams
 				local status, deflate_stream = pcall(zlib.deflate, compression_level);
@@ -116,10 +116,12 @@
 						return true;
 					end;
 				session.compressed = true;
-			else
+			elseif method then
 				session.log("info", "%s compression selected, but we don't support it.", tostring(method));
 				local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("unsupported-method");
 				session.send(error_st);
+			else
+				session.send(st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"));
 			end
 		end
 );