diff options
author | Kim Alvefur <zash@zash.se> | 2023-05-14 18:38:22 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-05-14 18:38:22 +0200 |
commit | f064c099a2a1c3f49cb29dbab6ca934c267fd484 (patch) | |
tree | 26f1163d6f1bd9f5bbf98718e29762580e5a50cc /net/http | |
parent | e80cd078fd8fd352453ba97733b319b1de88413d (diff) | |
download | prosody-f064c099a2a1c3f49cb29dbab6ca934c267fd484.tar.gz prosody-f064c099a2a1c3f49cb29dbab6ca934c267fd484.zip |
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.
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/server.lua | 3 |
1 files changed, 3 insertions, 0 deletions
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; |