aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2016-07-07 23:07:19 +0100
committerMatthew Wild <mwild1@gmail.com>2016-07-07 23:07:19 +0100
commita92512707cbad6f73ba9e85353a40aac23e85358 (patch)
treec403818f50bc69d7c0a83dea324a5125020c0d82
parent8afacb5d92d6098f6eb85bbc32aff5632983bd5d (diff)
downloadprosody-a92512707cbad6f73ba9e85353a40aac23e85358.tar.gz
prosody-a92512707cbad6f73ba9e85353a40aac23e85358.zip
net.http: Add request.id to every request object (can be overridden by providing ex.id)
-rw-r--r--net/http.lua4
1 files changed, 4 insertions, 0 deletions
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;