Merge 0.7->trunk
authorMatthew Wild <mwild1@gmail.com>
Wed, 9 Jun 2010 00:11:12 +0000 (01:11 +0100)
committerMatthew Wild <mwild1@gmail.com>
Wed, 9 Jun 2010 00:11:12 +0000 (01:11 +0100)
1  2 
plugins/mod_compression.lua

index 0e1aab8c83beb74a808847d03566b99f55c72666,5ff4781acbf12083afb6e2749875be0e87a976da..689a322f09ec9150402b819b2de1ad66fd9e7ab4
@@@ -95,20 -94,25 +95,19 @@@ en
  
  -- setup compression for a stream
  local function setup_compression(session, deflate_stream)
 -      local old_send = (session.sends2s or session.send);
 -      
 -      local new_send = function(t)
 -                      --TODO: Better code injection in the sending process
 -                      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", "%s", tostring(compressed));
 -                              return;
 -                      end
 -                      session.conn:write(compressed);
 -              end;
 -      
 -      if session.sends2s then session.sends2s = new_send
 -      elseif session.send then session.send = new_send end
 +      add_filter(session, "bytes/out", function(t)
-               session.log(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", "%s", tostring(compressed));
 +                      return;
 +              end
 +              return compressed;
 +      end);   
  end
  
  -- setup decompression for a stream