net.http.server: Log request and response status lines

Points out the beginning and end of a request.
This commit is contained in:
Kim Alvefur 2023-05-14 18:44:38 +02:00
parent fe8e6dc8ca
commit ff0b9242e3

View file

@ -236,6 +236,8 @@ function handle_request(conn, request, finish_cb)
request.headers = headers; request.headers = headers;
request.conn = conn; request.conn = conn;
request.log("debug", "%s %s HTTP/%s", request.method, request.path, request.httpversion);
local date_header = os_date('!%a, %d %b %Y %H:%M:%S GMT'); -- FIXME use local date_header = os_date('!%a, %d %b %Y %H:%M:%S GMT'); -- FIXME use
local conn_header = request.headers.connection; local conn_header = request.headers.connection;
conn_header = conn_header and ","..conn_header:gsub("[ \t]", ""):lower().."," or "" conn_header = conn_header and ","..conn_header:gsub("[ \t]", ""):lower().."," or ""
@ -327,6 +329,7 @@ end
local function prepare_header(response) local function prepare_header(response)
local status_line = "HTTP/"..response.request.httpversion.." "..(response.status or codes[response.status_code]); local status_line = "HTTP/"..response.request.httpversion.." "..(response.status or codes[response.status_code]);
response.log("debug", "%s", status_line);
local headers = response.headers; local headers = response.headers;
local output = { status_line }; local output = { status_line };
for k,v in pairs(headers) do for k,v in pairs(headers) do