Skip to content

Commit

Permalink
Fix charset not working properly for REST
Browse files Browse the repository at this point in the history
  • Loading branch information
essen committed Dec 10, 2012
1 parent 6d4e157 commit 08a4975
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cowboy_rest.erl
Expand Up @@ -40,7 +40,7 @@
language_a :: undefined | binary(),

%% Charset.
charsets_p = [] :: [binary()],
charsets_p = [] :: [{binary(), integer()}],
charset_a :: undefined | binary(),

%% Cached resource calls.
Expand Down Expand Up @@ -373,7 +373,7 @@ charsets_provided(Req, State) ->
case AcceptCharset of
undefined ->
set_content_type(Req3, State2#state{
charset_a=hd(CP)});
charset_a=element(1, hd(CP))});
AcceptCharset ->
AcceptCharset2 = prioritize_charsets(AcceptCharset),
choose_charset(Req3, State2, AcceptCharset2)
Expand Down Expand Up @@ -403,7 +403,7 @@ choose_charset(Req, State=#state{charsets_p=CP}, [Charset|Tail]) ->

match_charset(Req, State, Accept, [], _Charset) ->
choose_charset(Req, State, Accept);
match_charset(Req, State, _Accept, [Provided|_], {Provided, _}) ->
match_charset(Req, State, _Accept, [{Provided, _}|_], {Provided, _}) ->
set_content_type(Req, State#state{charset_a=Provided});
match_charset(Req, State, Accept, [_|Tail], Charset) ->
match_charset(Req, State, Accept, Tail, Charset).
Expand Down

0 comments on commit 08a4975

Please sign in to comment.