aboutsummaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-02-16 15:59:26 +0000
committerMatthew Wild <mwild1@gmail.com>2023-02-16 15:59:26 +0000
commitbc1e51eb8357bcb377f6010b79bd15607286302c (patch)
tree6eb6fc046f7c0d79aa7b8b9182db9cd60ba4eda7 /net/http
parent0fd88a07a4951d6e06e20f7c3dcc5c115cd78ace (diff)
downloadprosody-bc1e51eb8357bcb377f6010b79bd15607286302c.tar.gz
prosody-bc1e51eb8357bcb377f6010b79bd15607286302c.zip
net.http.server: Add new API to get HTTP request from a connection
This information is sometimes necessary in the context where we have a connection that we know (or believe to be) associated with an incoming HTTP request. For example, it can be used to retrieve the IP address of a request (which may differ from the IP address of the connection, due to X-Forwarded-For and co). Thanks to the Jitsi team for highlighting this gap in the API.
Diffstat (limited to 'net/http')
-rw-r--r--net/http/server.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/http/server.lua b/net/http/server.lua
index 4ebf96a1..43e6bc9f 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -428,6 +428,10 @@ end
function _M.set_option(name, value)
options[name] = value;
end
+function _M.get_request_from_conn(conn)
+ local response = conn and conn._http_open_response;
+ return response and response.request or nil;
+end
_M.listener = listener;
_M.codes = codes;