aboutsummaryrefslogtreecommitdiffstats
path: root/net
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
commit7d1211bac12c5c8684da51d70b5231a952544ac6 (patch)
tree8d46c41b1d289111ff17971d62620181ae411b00 /net
parentab114b1b5f001020b8ee628c42c4f333c5bb32ef (diff)
downloadprosody-7d1211bac12c5c8684da51d70b5231a952544ac6.tar.gz
prosody-7d1211bac12c5c8684da51d70b5231a952544ac6.zip
net.httpserver: Make it possible to return responses with no body
Diffstat (limited to 'net')
-rw-r--r--net/httpserver.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/httpserver.lua b/net/httpserver.lua
index 40bcd9df..cf51521f 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;
@@ -46,12 +46,12 @@ local function send_response(request, response)
t_insert(resp, k..": "..v.."\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: "..#body.."\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
request.write(t_concat(resp));