aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_protocol.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-09-29 13:03:45 +0200
committerLoïc Hoguin <[email protected]>2012-09-29 13:03:45 +0200
commitce9aff19f036310dd33d00d14cff35a559b8ccb1 (patch)
treea0f659e95429ef465cfcaf40c28be759f47ef907 /src/cowboy_protocol.erl
parentc326a195e0b1a8d1b8ea338ae9e98d8606895641 (diff)
downloadcowboy-ce9aff19f036310dd33d00d14cff35a559b8ccb1.tar.gz
cowboy-ce9aff19f036310dd33d00d14cff35a559b8ccb1.tar.bz2
cowboy-ce9aff19f036310dd33d00d14cff35a559b8ccb1.zip
Remove the urldecode cowboy_protocol option
This allows inconsistent behavior and is not used enough to be supported.
Diffstat (limited to 'src/cowboy_protocol.erl')
-rw-r--r--src/cowboy_protocol.erl21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl
index 77ddc2e..a9ce69c 100644
--- a/src/cowboy_protocol.erl
+++ b/src/cowboy_protocol.erl
@@ -22,9 +22,6 @@
%% Defaults to 5.</dd>
%% <dt>timeout</dt><dd>Time in milliseconds before an idle
%% connection is closed. Defaults to 5000 milliseconds.</dd>
-%% <dt>urldecode</dt><dd>Function and options argument to use when decoding
-%% URL encoded strings. Defaults to `{fun cowboy_http:urldecode/2, crash}'.
-%% </dd>
%% </dl>
%%
%% Note that there is no need to monitor these processes when using Cowboy as
@@ -56,7 +53,6 @@
dispatch :: cowboy_dispatcher:dispatch_rules(),
onrequest :: undefined | onrequest_fun(),
onresponse = undefined :: undefined | onresponse_fun(),
- urldecode :: {fun((binary(), T) -> binary()), T},
max_empty_lines :: integer(),
req_keepalive = 1 :: integer(),
max_keepalive :: integer(),
@@ -99,8 +95,6 @@ init(ListenerPid, Socket, Transport, Opts) ->
OnRequest = get_value(onrequest, Opts, undefined),
OnResponse = get_value(onresponse, Opts, undefined),
Timeout = get_value(timeout, Opts, 5000),
- URLDecDefault = {fun cowboy_http:urldecode/2, crash},
- URLDec = get_value(urldecode, Opts, URLDecDefault),
ok = ranch:accept_ack(ListenerPid),
wait_request(<<>>, #state{listener=ListenerPid, socket=Socket,
transport=Transport, dispatch=Dispatch,
@@ -108,8 +102,7 @@ init(ListenerPid, Socket, Transport, Opts) ->
max_request_line_length=MaxRequestLineLength,
max_header_name_length=MaxHeaderNameLength,
max_header_value_length=MaxHeaderValueLength,
- timeout=Timeout, onrequest=OnRequest, onresponse=OnResponse,
- urldecode=URLDec}, 0).
+ timeout=Timeout, onrequest=OnRequest, onresponse=OnResponse}, 0).
%% Request parsing.
%%
@@ -421,11 +414,11 @@ parse_host(<< C, Rest/bits >>, Acc) ->
request(Buffer, State=#state{socket=Socket, transport=Transport,
req_keepalive=ReqKeepalive, max_keepalive=MaxKeepalive,
- onresponse=OnResponse, urldecode=URLDecode},
+ onresponse=OnResponse},
Method, Path, Query, Fragment, Version, Headers, Host, Port) ->
Req = cowboy_req:new(Socket, Transport, Method, Path, Query, Fragment,
Version, Headers, Host, Port, Buffer, ReqKeepalive < MaxKeepalive,
- OnResponse, URLDecode),
+ OnResponse),
onrequest(Req, State, Host, Path).
%% Call the global onrequest callback. The callback can send a reply,
@@ -443,10 +436,8 @@ onrequest(Req, State=#state{onrequest=OnRequest}, Host, Path) ->
end.
-spec dispatch(cowboy_req:req(), #state{}, binary(), binary()) -> ok.
-dispatch(Req, State=#state{dispatch=Dispatch, urldecode={URLDecFun, URLDecArg}},
- Host, Path) ->
- case cowboy_dispatcher:match(Dispatch,
- fun(Bin) -> URLDecFun(Bin, URLDecArg) end, Host, Path) of
+dispatch(Req, State=#state{dispatch=Dispatch}, Host, Path) ->
+ case cowboy_dispatcher:match(Dispatch, Host, Path) of
{ok, Handler, Opts, Bindings, HostInfo, PathInfo} ->
Req2 = cowboy_req:set_bindings(HostInfo, PathInfo, Bindings, Req),
handler_init(Req2, State, Handler, Opts);
@@ -620,7 +611,7 @@ error_terminate(Code, State=#state{socket=Socket, transport=Transport,
after 0 ->
_ = cowboy_req:reply(Code, cowboy_req:new(Socket, Transport,
<<"GET">>, <<>>, <<>>, <<>>, {1, 1}, [], <<>>, undefined,
- <<>>, false, OnResponse, undefined)),
+ <<>>, false, OnResponse)),
ok
end,
terminate(State).