Comparison

plugins/mod_compression.lua @ 3127:94639081f327

mod_compression: Update for new session.data() syntax, fixes invalid XML errors after compression negotiation (thanks hg bisect)
author Matthew Wild <mwild1@gmail.com>
date Sat, 29 May 2010 02:08:11 +0100
parent 2892:9f214431de29
child 3148:a83a995fe5db
comparison
equal deleted inserted replaced
3034:b9ebd44a35f9 3127:94639081f327
117 end 117 end
118 118
119 -- setup decompression for a stream 119 -- setup decompression for a stream
120 local function setup_decompression(session, inflate_stream) 120 local function setup_decompression(session, inflate_stream)
121 local old_data = session.data 121 local old_data = session.data
122 session.data = function(conn, data) 122 session.data = function(data)
123 local status, decompressed, eof = pcall(inflate_stream, data); 123 local status, decompressed, eof = pcall(inflate_stream, data);
124 if status == false then 124 if status == false then
125 session:close({ 125 session:close({
126 condition = "undefined-condition"; 126 condition = "undefined-condition";
127 text = decompressed; 127 text = decompressed;
128 extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); 128 extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed");
129 }); 129 });
130 module:log("warn", "%s", tostring(decompressed)); 130 module:log("warn", "%s", tostring(decompressed));
131 return; 131 return;
132 end 132 end
133 old_data(conn, decompressed); 133 old_data(decompressed);
134 end; 134 end;
135 end 135 end
136 136
137 module:add_handler({"s2sout_unauthed", "s2sout"}, "compressed", xmlns_compression_protocol, 137 module:add_handler({"s2sout_unauthed", "s2sout"}, "compressed", xmlns_compression_protocol,
138 function(session ,stanza) 138 function(session ,stanza)