Software /
code /
prosody
Changeset
2283:156bb00ba5c0
mod_compression: Moving compression setup in a dedicated function.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sun, 29 Nov 2009 22:18:06 +0100 |
parents | 2282:6f54dac3ec2d |
children | 2284:491b89d6816b |
files | plugins/mod_compression.lua |
diffstat | 1 files changed, 17 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_compression.lua Sun Nov 29 22:02:21 2009 +0100 +++ b/plugins/mod_compression.lua Sun Nov 29 22:18:06 2009 +0100 @@ -108,21 +108,24 @@ end -- setup compression for session.w - local old_send = session.send; + local function setup_compression(session) + local old_send = session.send; - session.send = function(t) - local status, compressed, eof = pcall(deflate_stream, tostring(t), 'sync'); - if status == false then - session:close({ - condition = "undefined-condition"; - text = compressed; - extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); - }); - module:log("warn", compressed); - return; - end - old_send(compressed); - end; + session.send = function(t) + local status, compressed, eof = pcall(deflate_stream, tostring(t), 'sync'); + if status == false then + session:close({ + condition = "undefined-condition"; + text = compressed; + extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); + }); + module:log("warn", compressed); + return; + end + old_send(compressed); + end; + end + setup_compression(session); -- setup decompression for session.data local function setup_decompression(session)