aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_rest.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-12-12 08:23:34 +0100
committerLoïc Hoguin <[email protected]>2011-12-12 08:23:34 +0100
commit874cdd3bda849d091ea4e418ffda8a591f0f44a6 (patch)
tree6e5f6af6d8dacef645f8718cb448ad7fcbc5ca22 /src/cowboy_http_rest.erl
parentf445f16f608fe2942b994014b8ea13d44de9ef8a (diff)
parent2644a6caccc0510bf554e632fa63c8486cda252d (diff)
downloadcowboy-874cdd3bda849d091ea4e418ffda8a591f0f44a6.tar.gz
cowboy-874cdd3bda849d091ea4e418ffda8a591f0f44a6.tar.bz2
cowboy-874cdd3bda849d091ea4e418ffda8a591f0f44a6.zip
Merge branch 'variances-fix' of github.com:klaar/cowboy
Diffstat (limited to 'src/cowboy_http_rest.erl')
-rw-r--r--src/cowboy_http_rest.erl30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/cowboy_http_rest.erl b/src/cowboy_http_rest.erl
index d8d2f22..474964f 100644
--- a/src/cowboy_http_rest.erl
+++ b/src/cowboy_http_rest.erl
@@ -420,20 +420,20 @@ not_acceptable(Req, State) ->
%% @todo Does the order matter?
variances(Req, State=#state{content_types_p=CTP,
languages_p=LP, charsets_p=CP}) ->
- Variances = case length(CTP) of
- 0 -> [];
- 1 -> [];
- _NCT -> [<<"Accept">>]
+ Variances = case CTP of
+ [] -> [];
+ [_] -> [];
+ [_|_] -> [<<"Accept">>]
end,
- Variances2 = case length(LP) of
- 0 -> Variances;
- 1 -> Variances;
- _NL -> [<<"Accept-Language">>|Variances]
+ Variances2 = case LP of
+ [] -> Variances;
+ [_] -> Variances;
+ [_|_] -> [<<"Accept-Language">>|Variances]
end,
- Variances3 = case length(CP) of
- 0 -> Variances2;
- 1 -> Variances2;
- _NC -> [<<"Accept-Charset">>|Variances2]
+ Variances3 = case CP of
+ [] -> Variances2;
+ [_] -> Variances2;
+ [_|_] -> [<<"Accept-Charset">>|Variances2]
end,
{Variances4, Req3, State2} = case call(Req, State, variances) of
no_call ->
@@ -442,12 +442,12 @@ variances(Req, State=#state{content_types_p=CTP,
{Variances3 ++ HandlerVariances, Req2,
State#state{handler_state=HandlerState}}
end,
- case lists:flatten([[<<", ">>, V] || V <- Variances4]) of
+ case [[<<", ">>, V] || V <- Variances4] of
[] ->
resource_exists(Req3, State2);
- [<<", ">>, Variances5] ->
+ [[<<", ">>, H]|Variances5] ->
{ok, Req4} = cowboy_http_req:set_resp_header(
- <<"Variances">>, Variances5, Req3),
+ <<"Variances">>, [H|Variances5], Req3),
resource_exists(Req4, State2)
end.