# HG changeset patch # User Waqas Hussain # Date 1268147687 -18000 # Node ID 3baee526d7149b12a1633621878e1d4b481d2a41 # Parent ae72c0dd6f1f597abdbdaf1447eb035912e4aa5c mod_compression: Return instead of where applicable. diff -r ae72c0dd6f1f -r 3baee526d714 plugins/mod_compression.lua --- 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 );