Diff

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
line wrap: on
line diff
--- a/plugins/mod_bosh.lua	Tue May 15 14:00:57 2012 +0200
+++ b/plugins/mod_bosh.lua	Tue May 15 13:35:09 2012 +0100
@@ -98,13 +98,6 @@
 	end
 end
 
-local function handle_GET(request)
-	return [[<html><body>
-	<p>It works! Now point your BOSH client to this URL to connect to Prosody.</p>
-	<p>For more information see <a href="http://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p>
-</body></html>]];
-end
-
 function handle_OPTIONS(request)
 	local headers = {};
 	for k,v in pairs(default_headers) do headers[k] = v; end
@@ -428,13 +421,24 @@
 end
 module:add_timer(1, on_timer);
 
+
+local GET_response = {
+	headers = {
+		content_type = "text/html";
+	};
+	body = [[<html><body>
+	<p>It works! Now point your BOSH client to this URL to connect to Prosody.</p>
+	<p>For more information see <a href="http://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p>
+	</body></html>]];
+};
+
 function module.add_host(module)
 	module:depends("http");
 	module:provides("http", {
 		default_path = "/http-bind";
 		route = {
-			["GET"] = handle_GET;
-			["GET /"] = handle_GET;
+			["GET"] = GET_response;
+			["GET /"] = GET_response;
 			["OPTIONS"] = handle_OPTIONS;
 			["OPTIONS /"] = handle_OPTIONS;
 			["POST"] = handle_POST;