From fc9bcc9b207b16ce512e81f9eb0ab5fd89240afe Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 7 Jul 2016 23:07:19 +0100 Subject: net.http: Add request.id to every request object (can be overridden by providing ex.id) --- net/http.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/http.lua b/net/http.lua index b78f8438..5fa0c0a9 100644 --- a/net/http.lua +++ b/net/http.lua @@ -27,6 +27,8 @@ local _ENV = nil; local requests = {}; -- Open requests +local function make_id(req) return (tostring(req):match("%x+$")); end + local listener = { default_port = 80, default_mode = "*a" }; function listener.onconnect(conn) @@ -125,6 +127,8 @@ local function request(u, ex, callback) req.path = "/"; end + req.id = ex and ex.id or make_id(req); + local method, headers, body; local host, port = req.host, req.port; -- cgit v1.2.3