Software /
code /
prosody
Comparison
plugins/mod_compression.lua @ 2891:955a12ac985e
Merge 0.6 with waqas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 18 Mar 2010 01:16:39 +0000 |
parent | 2890:6273d4672cb4 |
child | 2892:9f214431de29 |
comparison
equal
deleted
inserted
replaced
2889:c1e6df7cf56a | 2891:955a12ac985e |
---|---|
40 function(session, stanza) | 40 function(session, stanza) |
41 -- fail if we are already compressed | 41 -- fail if we are already compressed |
42 if session.compressed then | 42 if session.compressed then |
43 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); | 43 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); |
44 session.send(error_st); | 44 session.send(error_st); |
45 session.log("warn", "Tried to establish another compression layer."); | 45 session.log("debug", "Client tried to establish another compression layer."); |
46 return; | 46 return; |
47 end | 47 end |
48 | 48 |
49 -- checking if the compression method is supported | 49 -- checking if the compression method is supported |
50 local method = stanza:child_with_name("method"); | 50 local method = stanza:child_with_name("method"); |
67 session.log("error", "Failed to create zlib.inflate filter."); | 67 session.log("error", "Failed to create zlib.inflate filter."); |
68 module:log("error", "%s", tostring(inflate_stream)); | 68 module:log("error", "%s", tostring(inflate_stream)); |
69 return | 69 return |
70 end | 70 end |
71 | 71 |
72 session.log("info", method.." compression selected."); | 72 session.log("debug", "zlib compression enabled."); |
73 session.send(st.stanza("compressed", {xmlns=xmlns_compression_protocol})); | 73 session.send(st.stanza("compressed", {xmlns=xmlns_compression_protocol})); |
74 session:reset_stream(); | 74 session:reset_stream(); |
75 | 75 |
76 -- setup compression for session.w | 76 -- setup compression for session.w |
77 local old_send = session.send; | 77 local old_send = session.send; |
115 setup_decompression(session); | 115 setup_decompression(session); |
116 return true; | 116 return true; |
117 end; | 117 end; |
118 session.compressed = true; | 118 session.compressed = true; |
119 elseif method then | 119 elseif method then |
120 session.log("info", "%s compression selected, but we don't support it.", tostring(method)); | 120 session.log("debug", "%s compression selected, but we don't support it.", tostring(method)); |
121 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("unsupported-method"); | 121 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("unsupported-method"); |
122 session.send(error_st); | 122 session.send(error_st); |
123 else | 123 else |
124 session.send(st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed")); | 124 session.send(st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed")); |
125 end | 125 end |