Software /
code /
prosody
Comparison
net/http/server.lua @ 13102:4e112b87543d
net.http.server: Log request and response status lines
Points out the beginning and end of a request.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 14 May 2023 18:44:38 +0200 |
parent | 13101:c975dafa4303 |
child | 13103:42c2a9787242 |
comparison
equal
deleted
inserted
replaced
13101:c975dafa4303 | 13102:4e112b87543d |
---|---|
234 local headers = {}; | 234 local headers = {}; |
235 for k,v in pairs(request.headers) do headers[k:gsub("-", "_")] = v; end | 235 for k,v in pairs(request.headers) do headers[k:gsub("-", "_")] = v; end |
236 request.headers = headers; | 236 request.headers = headers; |
237 request.conn = conn; | 237 request.conn = conn; |
238 | 238 |
239 request.log("debug", "%s %s HTTP/%s", request.method, request.path, request.httpversion); | |
240 | |
239 local date_header = os_date('!%a, %d %b %Y %H:%M:%S GMT'); -- FIXME use | 241 local date_header = os_date('!%a, %d %b %Y %H:%M:%S GMT'); -- FIXME use |
240 local conn_header = request.headers.connection; | 242 local conn_header = request.headers.connection; |
241 conn_header = conn_header and ","..conn_header:gsub("[ \t]", ""):lower().."," or "" | 243 conn_header = conn_header and ","..conn_header:gsub("[ \t]", ""):lower().."," or "" |
242 local httpversion = request.httpversion | 244 local httpversion = request.httpversion |
243 local persistent = conn_header:find(",keep-alive,", 1, true) | 245 local persistent = conn_header:find(",keep-alive,", 1, true) |
325 return handle_result(request, response, result); | 327 return handle_result(request, response, result); |
326 end | 328 end |
327 | 329 |
328 local function prepare_header(response) | 330 local function prepare_header(response) |
329 local status_line = "HTTP/"..response.request.httpversion.." "..(response.status or codes[response.status_code]); | 331 local status_line = "HTTP/"..response.request.httpversion.." "..(response.status or codes[response.status_code]); |
332 response.log("debug", "%s", status_line); | |
330 local headers = response.headers; | 333 local headers = response.headers; |
331 local output = { status_line }; | 334 local output = { status_line }; |
332 for k,v in pairs(headers) do | 335 for k,v in pairs(headers) do |
333 t_insert(output, headerfix[k]..v); | 336 t_insert(output, headerfix[k]..v); |
334 end | 337 end |