mod_http_upload: Handle HEAD requests in 0.10 when reading body from a file handle
--- a/mod_http_upload/mod_http_upload.lua Tue Aug 15 21:14:55 2017 +0200
+++ b/mod_http_upload/mod_http_upload.lua Wed Aug 16 00:01:14 2017 +0200
@@ -256,8 +256,12 @@
local status_line = "HTTP/"..response.request.httpversion.." "..(response.status or codes[response.status_code]);
local headers = response.headers;
- body = body or response.body or "";
- headers.content_length = #body;
+ if type(body) == "string" then
+ headers.content_length = #body;
+ elseif io.type(body) == "file" then
+ headers.content_length = body:seek("end");
+ body:close();
+ end
local output = { status_line };
for k,v in pairs(headers) do
@@ -282,6 +286,7 @@
local function serve_head(event, path)
event.response.send = send_response_sans_body;
+ event.response.send_file = send_response_sans_body;
return serve_uploaded_files(event, path);
end