Comparison

plugins/mod_bosh.lua @ 4880:6d96e2e717c1

mod_bosh: Set Content-Type to text/html for GET response (thanks Medics)
author Matthew Wild <mwild1@gmail.com>
date Tue, 15 May 2012 13:35:09 +0100
parent 4769:c91bb217bf79
child 4998:f6c1f98419be
comparison
equal deleted inserted replaced
4879:45bb378a4a98 4880:6d96e2e717c1
94 if max_inactive and #requests == 0 then 94 if max_inactive and #requests == 0 then
95 inactive_sessions[session] = os_time() + max_inactive; 95 inactive_sessions[session] = os_time() + max_inactive;
96 (session.log or log)("debug", "BOSH session marked as inactive (for %ds)", max_inactive); 96 (session.log or log)("debug", "BOSH session marked as inactive (for %ds)", max_inactive);
97 end 97 end
98 end 98 end
99 end
100
101 local function handle_GET(request)
102 return [[<html><body>
103 <p>It works! Now point your BOSH client to this URL to connect to Prosody.</p>
104 <p>For more information see <a href="http://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p>
105 </body></html>]];
106 end 99 end
107 100
108 function handle_OPTIONS(request) 101 function handle_OPTIONS(request)
109 local headers = {}; 102 local headers = {};
110 for k,v in pairs(default_headers) do headers[k] = v; end 103 for k,v in pairs(default_headers) do headers[k] = v; end
426 end 419 end
427 return 1; 420 return 1;
428 end 421 end
429 module:add_timer(1, on_timer); 422 module:add_timer(1, on_timer);
430 423
424
425 local GET_response = {
426 headers = {
427 content_type = "text/html";
428 };
429 body = [[<html><body>
430 <p>It works! Now point your BOSH client to this URL to connect to Prosody.</p>
431 <p>For more information see <a href="http://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p>
432 </body></html>]];
433 };
434
431 function module.add_host(module) 435 function module.add_host(module)
432 module:depends("http"); 436 module:depends("http");
433 module:provides("http", { 437 module:provides("http", {
434 default_path = "/http-bind"; 438 default_path = "/http-bind";
435 route = { 439 route = {
436 ["GET"] = handle_GET; 440 ["GET"] = GET_response;
437 ["GET /"] = handle_GET; 441 ["GET /"] = GET_response;
438 ["OPTIONS"] = handle_OPTIONS; 442 ["OPTIONS"] = handle_OPTIONS;
439 ["OPTIONS /"] = handle_OPTIONS; 443 ["OPTIONS /"] = handle_OPTIONS;
440 ["POST"] = handle_POST; 444 ["POST"] = handle_POST;
441 ["POST /"] = handle_POST; 445 ["POST /"] = handle_POST;
442 }; 446 };