Mercurial > prosody-hg
comparison plugins/mod_compression.lua @ 2892:9f214431de29
Merge 0.6->0.7
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 18 Mar 2010 01:25:50 +0000 |
| parents | 765e7070d0a8 6273d4672cb4 |
| children | 94639081f327 fd2389a240a2 |
comparison
equal
deleted
inserted
replaced
| 2887:765e7070d0a8 | 2892:9f214431de29 |
|---|---|
| 168 function(session, stanza) | 168 function(session, stanza) |
| 169 -- fail if we are already compressed | 169 -- fail if we are already compressed |
| 170 if session.compressed then | 170 if session.compressed then |
| 171 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); | 171 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); |
| 172 (session.sends2s or session.send)(error_st); | 172 (session.sends2s or session.send)(error_st); |
| 173 session.log("warn", "Tried to establish another compression layer."); | 173 session.log("debug", "Client tried to establish another compression layer."); |
| 174 return; | 174 return; |
| 175 end | 175 end |
| 176 | 176 |
| 177 -- checking if the compression method is supported | 177 -- checking if the compression method is supported |
| 178 local method = stanza:child_with_name("method"); | 178 local method = stanza:child_with_name("method"); |
| 179 method = method and (method[1] or ""); | 179 method = method and (method[1] or ""); |
| 180 if method == "zlib" then | 180 if method == "zlib" then |
| 181 session.log("debug", "%s compression selected.", tostring(method)); | 181 session.log("debug", "zlib compression enabled."); |
| 182 | 182 |
| 183 -- create deflate and inflate streams | 183 -- create deflate and inflate streams |
| 184 local deflate_stream = get_deflate_stream(session); | 184 local deflate_stream = get_deflate_stream(session); |
| 185 if not deflate_stream then return end | 185 if not deflate_stream then return end |
| 186 | 186 |
| 202 setup_decompression(session, inflate_stream); | 202 setup_decompression(session, inflate_stream); |
| 203 return true; | 203 return true; |
| 204 end; | 204 end; |
| 205 session.compressed = true; | 205 session.compressed = true; |
| 206 elseif method then | 206 elseif method then |
| 207 session.log("info", "%s compression selected, but we don't support it.", tostring(method)); | 207 session.log("debug", "%s compression selected, but we don't support it.", tostring(method)); |
| 208 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("unsupported-method"); | 208 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("unsupported-method"); |
| 209 (session.sends2s or session.send)(error_st); | 209 (session.sends2s or session.send)(error_st); |
| 210 else | 210 else |
| 211 (session.sends2s or session.send)(st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed")); | 211 (session.sends2s or session.send)(st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed")); |
| 212 end | 212 end |
