# HG changeset patch # User Kim Alvefur # Date 1502834474 -7200 # Node ID 46b29a377bdf54d57b63a57a5917221e5ada36ca # Parent f43c77c69a8a54b410a69133c0f3ccfa9746f2d9 mod_http_upload: Handle HEAD requests in 0.10 when reading body from a file handle diff -r f43c77c69a8a -r 46b29a377bdf mod_http_upload/mod_http_upload.lua --- 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