Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed onrequest path-related issue #292

Merged
merged 1 commit into from Nov 27, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cowboy_protocol.erl
Expand Up @@ -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.

Expand Down