Merge 0.10->trunk
authorKim Alvefur <zash@zash.se>
Tue, 19 Apr 2016 15:10:42 +0000 (17:10 +0200)
committerKim Alvefur <zash@zash.se>
Tue, 19 Apr 2016 15:10:42 +0000 (17:10 +0200)
1  2 
plugins/mod_bosh.lua

index 47f0b3b43aadc6dbd57fa5a2b3c87890dfaa358e,d317e4b97683f1c894ecae60cfd71f3cc5a17db5..6acdc23cb749345b1d1bb4d558a0ab6dc84b8512
@@@ -22,7 -21,7 +22,6 @@@ local initialize_filters = require "uti
  local math_min = math.min;
  local xpcall, tostring, type = xpcall, tostring, type;
  local traceback = debug.traceback;
- local runner = require"util.async".runner;
 -local nameprep = require "util.encodings".stringprep.nameprep;
  
  local xmlns_streams = "http://etherx.jabber.org/streams";
  local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
@@@ -200,16 -183,15 +189,20 @@@ function handle_POST(event
                else
                        return true; -- Inform http server we shall reply later
                end
+       elseif response.finished then
+               return; -- A response has been sent already
        end
        module:log("warn", "Unable to associate request with a session (incomplete request?)");
-       return 400;
+       local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate",
+               ["xmlns:stream"] = xmlns_streams, condition = "item-not-found" });
+       return tostring(close_reply) .. "\n";
  end
  
 +function after_bosh_wait(now, request, session)
 +      if request.conn then
 +              session.send("");
 +      end
 +end
  
  local function bosh_reset_stream(session) session.notopen = true; end