From f064c099a2a1c3f49cb29dbab6ca934c267fd484 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 14 May 2023 18:38:22 +0200 Subject: net.http.server: Assign an ID to each request, shared with response Goal is improve tracking of individual HTTP requests throughout its life-cycle. Having a single ID to use in logging should help here. --- net/http/server.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'net') diff --git a/net/http/server.lua b/net/http/server.lua index f2d0ab10..26af1b51 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -14,6 +14,7 @@ local promise = require "prosody.util.promise"; local errors = require "prosody.util.error"; local blocksize = 2^16; local async = require "prosody.util.async"; +local id = require"prosody.util.id"; local _M = {}; @@ -128,6 +129,7 @@ function listener.onconnect(conn) end, runner_callbacks, session); local function success_cb(request) --log("debug", "success_cb: %s", request.path); + request.id = id.short(); request.ip = ip; request.secure = secure; session.thread:run(request); @@ -249,6 +251,7 @@ function handle_request(conn, request, finish_cb) local is_head_request = request.method == "HEAD"; local response = { + id = request.id; request = request; is_head_request = is_head_request; status_code = 200; -- cgit v1.2.3