0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

charsets_provided/2 returns a list of charsets

It incorrectly returned a tuple containing the charset and an
associated quality which wasn't being used.
This commit is contained in:
Loïc Hoguin 2013-05-16 17:32:07 +02:00
parent 1d413ea51b
commit 08fcb38a18

View file

@ -45,7 +45,7 @@
language_a :: undefined | binary(),
%% Charset.
charsets_p = [] :: [{binary(), integer()}],
charsets_p = [] :: [binary()],
charset_a :: undefined | binary(),
%% Whether the resource exists.
@ -406,8 +406,7 @@ charsets_provided(Req, State) ->
cowboy_req:parse_header(<<"accept-charset">>, Req2),
case AcceptCharset of
undefined ->
set_content_type(Req3, State2#state{
charset_a=element(1, hd(CP))});
set_content_type(Req3, State2#state{charset_a=hd(CP)});
AcceptCharset ->
AcceptCharset2 = prioritize_charsets(AcceptCharset),
choose_charset(Req3, State2, AcceptCharset2)
@ -437,7 +436,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).