aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-01-21 13:14:52 +0000
committerMatthew Wild <mwild1@gmail.com>2010-01-21 13:14:52 +0000
commite79181eab31b87bbab91ff2cc73f43d529d4b2dc (patch)
tree496be73401e53d12d5232aa35bf70ca2bcc06936
parent4c3707ec7bb896d1efaccf63eed18aee8cd88ef8 (diff)
downloadprosody-e79181eab31b87bbab91ff2cc73f43d529d4b2dc.tar.gz
prosody-e79181eab31b87bbab91ff2cc73f43d529d4b2dc.zip
net.httpserver: Make it possible to return responses with no body
-rw-r--r--net/httpserver.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/httpserver.lua b/net/httpserver.lua
index 1341bfbb..e16d4de6 100644
--- a/net/httpserver.lua
+++ b/net/httpserver.lua
@@ -36,8 +36,8 @@ end
local function send_response(request, response)
-- Write status line
local resp;
- if response.body then
- local body = tostring(response.body);
+ if response.body or response.headers then
+ local body = response.body and 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;
@@ -49,14 +49,14 @@ local function send_response(request, response)
t_insert(resp, "\r\n");
end
end
- if not (h and h["Content-Length"]) then
+ if body and not (h and h["Content-Length"]) then
t_insert(resp, "Content-Length: ");
t_insert(resp, #body);
t_insert(resp, "\r\n");
end
t_insert(resp, "\r\n");
- if request.method ~= "HEAD" then
+ if body and request.method ~= "HEAD" then
t_insert(resp, body);
end
else