aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_compression.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-03-09 20:14:47 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-03-09 20:14:47 +0500
commitb3aafb2c908ee767656555086c9c08c471f5063a (patch)
treed5cef3374053a56b992486f187dd335254699038 /plugins/mod_compression.lua
parenta4d78f333f96d6a1fe08bdd66e1b7cdf1f0e124a (diff)
downloadprosody-b3aafb2c908ee767656555086c9c08c471f5063a.tar.gz
prosody-b3aafb2c908ee767656555086c9c08c471f5063a.zip
mod_compression: Return <setup-failed/> instead of <unsupported-method/> where applicable.
Diffstat (limited to 'plugins/mod_compression.lua')
-rw-r--r--plugins/mod_compression.lua8
1 files 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
);