From b3aafb2c908ee767656555086c9c08c471f5063a Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Tue, 9 Mar 2010 20:14:47 +0500 Subject: mod_compression: Return instead of where applicable. --- plugins/mod_compression.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/mod_compression.lua b/plugins/mod_compression.lua index 379927df..87ff6be7 100644 --- a/plugins/mod_compression.lua +++ b/plugins/mod_compression.lua @@ -40,7 +40,7 @@ module:add_handler({"c2s_unauthed", "c2s"}, "compress", xmlns_compression_protoc 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 @@ module:add_handler({"c2s_unauthed", "c2s"}, "compress", xmlns_compression_protoc -- 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 @@ module:add_handler({"c2s_unauthed", "c2s"}, "compress", xmlns_compression_protoc 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 ); -- cgit v1.2.3