Software /
code /
prosody
Comparison
plugins/mod_bosh.lua @ 7377:6c98e783272a
mod_bosh: Return a proper BOSH error response instead of deprecated(?) status code (See #343)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 19 Apr 2016 12:16:17 +0200 |
parent | 7376:f9a5d9f60561 |
child | 7378:d15cfe8627ad |
comparison
equal
deleted
inserted
replaced
7376:f9a5d9f60561 | 7377:6c98e783272a |
---|---|
127 -- much of the session logic happens, because it's where we first | 127 -- much of the session logic happens, because it's where we first |
128 -- get to see the 'sid' of this request. | 128 -- get to see the 'sid' of this request. |
129 local ok, err = stream:feed(body); | 129 local ok, err = stream:feed(body); |
130 if not ok then | 130 if not ok then |
131 module:log("warn", "Error parsing BOSH payload; %s", err) | 131 module:log("warn", "Error parsing BOSH payload; %s", err) |
132 return 400; | 132 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", |
133 ["xmlns:stream"] = xmlns_streams, condition = "bad-request" }); | |
134 return tostring(close_reply); | |
133 end | 135 end |
134 | 136 |
135 -- Stanzas (if any) in the request have now been processed, and | 137 -- Stanzas (if any) in the request have now been processed, and |
136 -- we take care of the high-level BOSH logic here, including | 138 -- we take care of the high-level BOSH logic here, including |
137 -- giving a response or putting the request "on hold". | 139 -- giving a response or putting the request "on hold". |
182 end | 184 end |
183 elseif response.finished then | 185 elseif response.finished then |
184 return; -- A response has been sent already | 186 return; -- A response has been sent already |
185 end | 187 end |
186 module:log("warn", "Unable to associate request with a session (incomplete request?)"); | 188 module:log("warn", "Unable to associate request with a session (incomplete request?)"); |
187 return 400; | 189 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", |
190 ["xmlns:stream"] = xmlns_streams, condition = "item-not-found" }); | |
191 return tostring(close_reply) .. "\n"; | |
188 end | 192 end |
189 | 193 |
190 | 194 |
191 local function bosh_reset_stream(session) session.notopen = true; end | 195 local function bosh_reset_stream(session) session.notopen = true; end |
192 | 196 |