Comparison

plugins/mod_bosh.lua @ 8765:d5ff0982d3e6

mod_bosh: Fix for 7be8f649d97d to skip error handling and allow other modules to handle the request
author Matthew Wild <mwild1@gmail.com>
date Sun, 29 Apr 2018 22:15:44 +0100
parent 8752:8f2da579a790
child 8767:7738838a013d
comparison
equal deleted inserted replaced
8764:81d305bbe7bc 8765:d5ff0982d3e6
189 session.bosh_wait_timer = module:add_timer(session.bosh_wait, after_bosh_wait, session.requests[1], session) 189 session.bosh_wait_timer = module:add_timer(session.bosh_wait, after_bosh_wait, session.requests[1], session)
190 end 190 end
191 191
192 return true; -- Inform http server we shall reply later 192 return true; -- Inform http server we shall reply later
193 end 193 end
194 elseif response.finished then 194 elseif response.finished or context.ignore_request then
195 return; -- A response has been sent already 195 -- A response has been sent already, or we're ignoring this request
196 -- (e.g. so a different instance of the module can handle it)
197 return;
196 end 198 end
197 module:log("warn", "Unable to associate request with a session (incomplete request?)"); 199 module:log("warn", "Unable to associate request with a session (incomplete request?)");
198 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", 200 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate",
199 ["xmlns:stream"] = xmlns_streams, condition = "item-not-found" }); 201 ["xmlns:stream"] = xmlns_streams, condition = "item-not-found" });
200 return tostring(close_reply) .. "\n"; 202 return tostring(close_reply) .. "\n";
267 response:send(tostring(close_reply)); 269 response:send(tostring(close_reply));
268 return; 270 return;
269 elseif to_host ~= module.host then 271 elseif to_host ~= module.host then
270 -- Could be meant for a different instance of the module 272 -- Could be meant for a different instance of the module
271 -- if multiple instances are loaded with the same URL then this can happen 273 -- if multiple instances are loaded with the same URL then this can happen
272 return; --> 404 274 context.ignore_request = true;
275 return;
273 end 276 end
274 if not rid or (not wait and attr.wait or wait < 0 or wait % 1 ~= 0) then 277 if not rid or (not wait and attr.wait or wait < 0 or wait % 1 ~= 0) then
275 log("debug", "BOSH client sent invalid rid or wait attributes: rid=%s, wait=%s", tostring(attr.rid), tostring(attr.wait)); 278 log("debug", "BOSH client sent invalid rid or wait attributes: rid=%s, wait=%s", tostring(attr.rid), tostring(attr.wait));
276 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", 279 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate",
277 ["xmlns:stream"] = xmlns_streams, condition = "bad-request" }); 280 ["xmlns:stream"] = xmlns_streams, condition = "bad-request" });