Diff

plugins/mod_compression.lua @ 2883:adbca5af8536

mod_compression: Don't tell client compression succeeded when it didn't.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 09 Mar 2010 17:52:18 +0500
parent 2882:4e72048d4a24
child 2884:6807f5fa0eb4
line wrap: on
line diff
--- a/plugins/mod_compression.lua	Tue Mar 09 17:43:18 2010 +0500
+++ b/plugins/mod_compression.lua	Tue Mar 09 17:52:18 2010 +0500
@@ -48,10 +48,6 @@
 			-- checking if the compression method is supported
 			local method = stanza:child_with_name("method")[1];
 			if method == "zlib" then
-				session.log("info", method.." compression selected.");
-				session.send(st.stanza("compressed", {xmlns=xmlns_compression_protocol}));
-				session:reset_stream();
-				
 				-- create deflate and inflate streams
 				local status, deflate_stream = pcall(zlib.deflate, compression_level);
 				if status == false then
@@ -71,6 +67,10 @@
 					return
 				end
 				
+				session.log("info", method.." compression selected.");
+				session.send(st.stanza("compressed", {xmlns=xmlns_compression_protocol}));
+				session:reset_stream();
+
 				-- setup compression for session.w
 				local old_send = session.send;