# HG changeset patch # User Matthew Wild # Date 1676563166 0 # Node ID 3a6dae39c70ebaa1c82dbc6a28c6e4369750e155 # Parent 9ed628635dc66da3fdc28af836efcb1a6428fc95 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. diff -r 9ed628635dc6 -r 3a6dae39c70e net/http/server.lua --- a/net/http/server.lua Thu Feb 09 22:57:32 2023 +0000 +++ b/net/http/server.lua Thu Feb 16 15:59:26 2023 +0000 @@ -428,6 +428,10 @@ 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;