aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2009-11-29 22:18:06 +0100
committerTobias Markmann <tm@ayena.de>2009-11-29 22:18:06 +0100
commitc7c629d9c8eda79fd6fd2d7e57f528d028554a50 (patch)
tree622d7a6e02d10c8bc00d3204becb97b599bab376 /plugins
parentb1743dfea11540cdf60fa26b560318f4a4b4fe84 (diff)
downloadprosody-c7c629d9c8eda79fd6fd2d7e57f528d028554a50.tar.gz
prosody-c7c629d9c8eda79fd6fd2d7e57f528d028554a50.zip
mod_compression: Moving compression setup in a dedicated function.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_compression.lua31
1 files changed, 17 insertions, 14 deletions
diff --git a/plugins/mod_compression.lua b/plugins/mod_compression.lua
index 72573b93..2a6c0871 100644
--- a/plugins/mod_compression.lua
+++ b/plugins/mod_compression.lua
@@ -108,21 +108,24 @@ module:add_handler({"c2s_unauthed", "c2s", "s2sin_unauthed", "s2sin"}, "compress
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)