Changeset

1634:46120978150c

Merge with 0.5
author Matthew Wild <mwild1@gmail.com>
date Wed, 05 Aug 2009 03:08:54 +0100
parents 1631:fa49cbfff0e6 (current diff) 1633:7812459eeed7 (diff)
children 1636:16e9ba7c4a03
files
diffstat 2 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/net/httpserver.lua	Mon Aug 03 17:53:02 2009 +0100
+++ b/net/httpserver.lua	Wed Aug 05 03:08:54 2009 +0100
@@ -37,6 +37,7 @@
 	-- Write status line
 	local resp;
 	if response.body then
+		local body = tostring(response.body);
 		log("debug", "Sending response to %s", request.id);
 		resp = { "HTTP/1.0 ", response.status or "200 OK", "\r\n"};
 		local h = response.headers;
@@ -48,15 +49,15 @@
 				t_insert(resp, "\r\n");
 			end
 		end
-		if response.body and not (h and h["Content-Length"]) then
+		if not (h and h["Content-Length"]) then
 			t_insert(resp, "Content-Length: ");
-			t_insert(resp, #response.body);
+			t_insert(resp, #body);
 			t_insert(resp, "\r\n");
 		end
 		t_insert(resp, "\r\n");
 		
-		if response.body and request.method ~= "HEAD" then
-			t_insert(resp, response.body);
+		if request.method ~= "HEAD" then
+			t_insert(resp, body);
 		end
 	else
 		-- Response we have is just a string (the body)
--- a/plugins/mod_bosh.lua	Mon Aug 03 17:53:02 2009 +0100
+++ b/plugins/mod_bosh.lua	Wed Aug 05 03:08:54 2009 +0100
@@ -136,8 +136,8 @@
 		if not hosts[attr.to] then
 			-- Unknown host
 			log("debug", "BOSH client tried to connect to unknown host: %s", tostring(attr.to));
-			session_close_reply.attr.condition = "host-unknown";
-			request:send{ headers = default_headers, body = tostring(session_close_reply) };
+			session_close_reply.body.attr.condition = "host-unknown";
+			request:send(session_close_reply);
 			request.notopen = nil
 			return;
 		end