Software /
code /
prosody
Comparison
net/http/server.lua @ 12885:3a6dae39c70e 0.12
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.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 16 Feb 2023 15:59:26 +0000 |
parent | 12831:1cdaf21584da |
child | 12886:686c3cdd4775 |
comparison
equal
deleted
inserted
replaced
12882:9ed628635dc6 | 12885:3a6dae39c70e |
---|---|
426 return events.fire_event(event, ...); | 426 return events.fire_event(event, ...); |
427 end | 427 end |
428 function _M.set_option(name, value) | 428 function _M.set_option(name, value) |
429 options[name] = value; | 429 options[name] = value; |
430 end | 430 end |
431 function _M.get_request_from_conn(conn) | |
432 local response = conn and conn._http_open_response; | |
433 return response and response.request or nil; | |
434 end | |
431 | 435 |
432 _M.listener = listener; | 436 _M.listener = listener; |
433 _M.codes = codes; | 437 _M.codes = codes; |
434 _M._events = events; | 438 _M._events = events; |
435 return _M; | 439 return _M; |