Comparison

plugins/mod_compression.lua @ 2885:ae72c0dd6f1f

mod_compression: More robust stanza processing.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 09 Mar 2010 18:19:50 +0500
parent 2884:6807f5fa0eb4
child 2886:3baee526d714
comparison
equal deleted inserted replaced
2884:6807f5fa0eb4 2885:ae72c0dd6f1f
45 session.log("warn", "Tried to establish another compression layer."); 45 session.log("warn", "Tried to establish another compression layer.");
46 return; 46 return;
47 end 47 end
48 48
49 -- checking if the compression method is supported 49 -- checking if the compression method is supported
50 local method = stanza:child_with_name("method")[1]; 50 local method = stanza:child_with_name("method");
51 method = method and method[1];
51 if method == "zlib" then 52 if method == "zlib" then
52 -- create deflate and inflate streams 53 -- create deflate and inflate streams
53 local status, deflate_stream = pcall(zlib.deflate, compression_level); 54 local status, deflate_stream = pcall(zlib.deflate, compression_level);
54 if status == false then 55 if status == false then
55 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); 56 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed");