comparison plugins/mod_compression.lua @ 6058:1607b03356ed

mod_compression: Only iterate over correctly named and namespaced child tags of compression feature
author Kim Alvefur <zash@zash.se>
date Thu, 03 Apr 2014 23:48:12 +0200
parents a3d7b8f4d9c7
children 769a3577dd85
comparison
equal deleted inserted replaced
6057:a3d7b8f4d9c7 6058:1607b03356ed
46 if not session.compressed and session.type == "s2sout" then 46 if not session.compressed and session.type == "s2sout" then
47 -- does remote server support compression? 47 -- does remote server support compression?
48 local comp_st = stanza:get_child("compression", xmlns_compression_feature); 48 local comp_st = stanza:get_child("compression", xmlns_compression_feature);
49 if comp_st then 49 if comp_st then
50 -- do we support the mechanism 50 -- do we support the mechanism
51 for a in comp_st:children() do 51 for a in comp_st:childtags("method") do
52 local algorithm = a[1] 52 local algorithm = a:get_text();
53 if algorithm == "zlib" then 53 if algorithm == "zlib" then
54 session.sends2s(st.stanza("compress", {xmlns=xmlns_compression_protocol}):tag("method"):text("zlib")) 54 session.sends2s(st.stanza("compress", {xmlns=xmlns_compression_protocol}):tag("method"):text("zlib"))
55 session.log("debug", "Enabled compression using zlib.") 55 session.log("debug", "Enabled compression using zlib.")
56 return true; 56 return true;
57 end 57 end