Diff

plugins/mod_xmlrpc.lua @ 880:ff4a08d73772

XML-RPC: Set appropriate Content-Type header in HTTP response
author Waqas Hussain <waqas20@gmail.com>
date Wed, 04 Mar 2009 22:59:58 +0500
parent 877:0bababc930dd
child 889:bb959588bbc4
line wrap: on
line diff
--- a/plugins/mod_xmlrpc.lua	Wed Mar 04 22:45:06 2009 +0500
+++ b/plugins/mod_xmlrpc.lua	Wed Mar 04 22:59:58 2009 +0500
@@ -102,6 +102,7 @@
 module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:rpc", handle_xmpp_request);
 module:add_feature("jabber:iq:rpc");
 
+local default_headers = { ["Content-Type"] = "text/xml" };
 local function handle_http_request(method, body, request)
 	local stanza = body and parse_xml(body);
 	if (not stanza) or request.method ~= "POST" then
@@ -109,8 +110,8 @@
 	end
 	local success, method, args = pcall(translate_request, stanza);
 	if success then
-		return tostring(handle_xmlrpc_request(method, args));
+		return { headers = default_headers; body = tostring(handle_xmlrpc_request(method, args)) };
 	end
-	return "<html><body>You really don't look like an XML-RPC client to me... what do you want?</body></html>";
+	return "<html><body>Error parsing XML-RPC request: "..tostring(method).."</body></html>";
 end
 httpserver.new{ port = 9000, base = "xmlrpc", handler = handle_http_request }