Software /
code /
prosody
Comparison
plugins/mod_bosh.lua @ 5647:8767b47524c9
mod_bosh: Return errors when appropriate (invalid XML, missing sid)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 05 Jun 2013 21:39:56 +0100 |
parent | 5646:c4b6ebea7185 |
child | 5648:f7f667c48d9a |
comparison
equal
deleted
inserted
replaced
5646:c4b6ebea7185 | 5647:8767b47524c9 |
---|---|
121 -- stream:feed() calls the stream_callbacks, so all stanzas in | 121 -- stream:feed() calls the stream_callbacks, so all stanzas in |
122 -- the body are processed in this next line before it returns. | 122 -- the body are processed in this next line before it returns. |
123 -- In particular, the streamopened() stream callback is where | 123 -- In particular, the streamopened() stream callback is where |
124 -- much of the session logic happens, because it's where we first | 124 -- much of the session logic happens, because it's where we first |
125 -- get to see the 'sid' of this request. | 125 -- get to see the 'sid' of this request. |
126 stream:feed(body); | 126 if not stream:feed(body) then |
127 module:log("warn", "Error parsing BOSH payload") | |
128 return 400; | |
129 end | |
127 | 130 |
128 -- Stanzas (if any) in the request have now been processed, and | 131 -- Stanzas (if any) in the request have now been processed, and |
129 -- we take care of the high-level BOSH logic here, including | 132 -- we take care of the high-level BOSH logic here, including |
130 -- giving a response or putting the request "on hold". | 133 -- giving a response or putting the request "on hold". |
131 local session = sessions[context.sid]; | 134 local session = sessions[context.sid]; |
172 return nil; | 175 return nil; |
173 else | 176 else |
174 return true; -- Inform http server we shall reply later | 177 return true; -- Inform http server we shall reply later |
175 end | 178 end |
176 end | 179 end |
180 module:log("warn", "Unable to associate request with a session (incomplete request?)"); | |
181 return 400; | |
177 end | 182 end |
178 | 183 |
179 | 184 |
180 local function bosh_reset_stream(session) session.notopen = true; end | 185 local function bosh_reset_stream(session) session.notopen = true; end |
181 | 186 |