diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_http_protocol.erl | 3 | ||||
-rw-r--r-- | src/cowboy_http_req.erl | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl index 2847646..f6047bf 100644 --- a/src/cowboy_http_protocol.erl +++ b/src/cowboy_http_protocol.erl @@ -65,11 +65,10 @@ request({http_request, _Method, _URI, Version}, State) request({http_request, Method, {abs_path, AbsPath}, Version}, State=#state{socket=Socket, transport=Transport}) -> {Path, RawPath, Qs} = cowboy_dispatcher:split_path(AbsPath), - {ok, Peer} = Transport:peername(Socket), ConnAtom = version_to_connection(Version), wait_header(#http_req{socket=Socket, transport=Transport, connection=ConnAtom, method=Method, version=Version, - peer=Peer, path=Path, raw_path=RawPath, raw_qs=Qs}, State); + path=Path, raw_path=RawPath, raw_qs=Qs}, State); request({http_request, Method, '*', Version}, State=#state{socket=Socket, transport=Transport}) -> {ok, Peer} = Transport:peername(Socket), diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl index 1938bc7..3dcac2f 100644 --- a/src/cowboy_http_req.erl +++ b/src/cowboy_http_req.erl @@ -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}. |