Comparison

plugins/compression.lua @ 380:0891b4e27766

Discard trailing whitespace
author Kim Alvefur <zash@zash.se>
date Fri, 01 May 2015 23:27:29 +0200
parent 250:a5ac643a7fd6
comparison
equal deleted inserted replaced
379:d80d27234e38 380:0891b4e27766
1 -- Copyright (C) 2009-2010 Matthew Wild 1 -- Copyright (C) 2009-2010 Matthew Wild
2 -- Copyright (C) 2009-2010 Tobias Markmann 2 -- Copyright (C) 2009-2010 Tobias Markmann
3 -- 3 --
4 -- This project is MIT/X11 licensed. Please see the 4 -- This project is MIT/X11 licensed. Please see the
5 -- COPYING file in the source package for more information. 5 -- COPYING file in the source package for more information.
6 -- 6 --
7 7
8 local verse = require "verse"; 8 local verse = require "verse";
51 }); 51 });
52 session:warn("Compressed send failed: %s", tostring(compressed)); 52 session:warn("Compressed send failed: %s", tostring(compressed));
53 return; 53 return;
54 end 54 end
55 session.conn:write(compressed); 55 session.conn:write(compressed);
56 end; 56 end;
57 end 57 end
58 58
59 -- setup decompression for a stream 59 -- setup decompression for a stream
60 local function setup_decompression(session, inflate_stream) 60 local function setup_decompression(session, inflate_stream)
61 local old_data = session.data 61 local old_data = session.data
99 stream:debug("Activating compression...") 99 stream:debug("Activating compression...")
100 100
101 -- create deflate and inflate streams 101 -- create deflate and inflate streams
102 local deflate_stream = get_deflate_stream(stream); 102 local deflate_stream = get_deflate_stream(stream);
103 if not deflate_stream then return end 103 if not deflate_stream then return end
104 104
105 local inflate_stream = get_inflate_stream(stream); 105 local inflate_stream = get_inflate_stream(stream);
106 if not inflate_stream then return end 106 if not inflate_stream then return end
107 107
108 -- setup compression for stream.w 108 -- setup compression for stream.w
109 setup_compression(stream, deflate_stream); 109 setup_compression(stream, deflate_stream);
110 110
111 -- setup decompression for stream.data 111 -- setup decompression for stream.data
112 setup_decompression(stream, inflate_stream); 112 setup_decompression(stream, inflate_stream);
113 113
114 stream.compressed = true; 114 stream.compressed = true;
115 stream:reopen(); 115 stream:reopen();
116 elseif stanza.name == "failure" then 116 elseif stanza.name == "failure" then
117 stream:warn("Failed to establish compression"); 117 stream:warn("Failed to establish compression");
118 end 118 end