diff options
author | Loïc Hoguin <[email protected]> | 2012-11-27 17:11:23 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2012-11-27 17:11:23 +0100 |
commit | 610f9e8d43f58d2ccbc54cb931c628855d03ff52 (patch) | |
tree | 22b606343d007096b1206f064c0d953ad90ecaa6 /src/cowboy_protocol.erl | |
parent | bb07b48d7f821ce3ec295837f7ec8ebd8da2cf35 (diff) | |
parent | d0f3372b7dd8f999281a8c45156423c4117aa4fb (diff) | |
download | cowboy-610f9e8d43f58d2ccbc54cb931c628855d03ff52.tar.gz cowboy-610f9e8d43f58d2ccbc54cb931c628855d03ff52.tar.bz2 cowboy-610f9e8d43f58d2ccbc54cb931c628855d03ff52.zip |
Merge branch 'onrequest' of git://github.com/saleyn/cowboy
Diffstat (limited to 'src/cowboy_protocol.erl')
-rw-r--r-- | src/cowboy_protocol.erl | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl index df2e963..f759d88 100644 --- a/src/cowboy_protocol.erl +++ b/src/cowboy_protocol.erl @@ -440,19 +440,19 @@ request(Buffer, State=#state{socket=Socket, transport=Transport, Req = cowboy_req:new(Socket, Transport, Method, Path, Query, Fragment, Version, Headers, Host, Port, Buffer, ReqKeepalive < MaxKeepalive, OnResponse), - onrequest(Req, State, Host, Path). + onrequest(Req, State, Host). %% Call the global onrequest callback. The callback can send a reply, %% in which case we consider the request handled and move on to the next %% one. Note that since we haven't dispatched yet, we don't know the %% handler, host_info, path_info or bindings yet. --spec onrequest(cowboy_req:req(), #state{}, binary(), binary()) -> ok. -onrequest(Req, State=#state{onrequest=undefined}, Host, Path) -> - dispatch(Req, State, Host, Path); -onrequest(Req, State=#state{onrequest=OnRequest}, Host, Path) -> +-spec onrequest(cowboy_req:req(), #state{}, binary()) -> ok. +onrequest(Req, State=#state{onrequest=undefined}, Host) -> + dispatch(Req, State, Host, cowboy_req:get(path, Req)); +onrequest(Req, State=#state{onrequest=OnRequest}, Host) -> Req2 = OnRequest(Req), case cowboy_req:get(resp_state, Req2) of - waiting -> dispatch(Req2, State, Host, Path); + waiting -> dispatch(Req2, State, Host, cowboy_req:get(path, Req2)); _ -> next_request(Req2, State, ok) end. |