mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 13:10:24 +00:00
Lazy-retrieve the peer name and port to avoid wasting time each request.
This commit is contained in:
parent
f5e7178651
commit
d69d0adfa7
2 changed files with 4 additions and 2 deletions
|
@ -44,6 +44,9 @@ version(Req) ->
|
|||
|
||||
-spec peer(Req::#http_req{})
|
||||
-> {{Address::ip_address(), Port::port_number()}, Req::#http_req{}}.
|
||||
peer(Req=#http_req{socket=Socket, transport=Transport, peer=undefined}) ->
|
||||
{ok, Peer} = Transport:peername(Socket),
|
||||
{Peer, Req#http_req{peer=Peer}};
|
||||
peer(Req) ->
|
||||
{Req#http_req.peer, Req}.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue