Skip to content

Commit

Permalink
REST: Fix charset matching
Browse files Browse the repository at this point in the history
  • Loading branch information
essen committed Jul 21, 2012
1 parent 86f9f48 commit 95ed134
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cowboy.app.src
Expand Up @@ -14,7 +14,7 @@

{application, cowboy, [
{description, "Small, fast, modular HTTP server."},
{vsn, "0.6.0"},
{vsn, git},
{modules, []},
{registered, [cowboy_clock, cowboy_sup]},
{applications, [
Expand Down
8 changes: 4 additions & 4 deletions src/cowboy_http_rest.erl
Expand Up @@ -367,7 +367,8 @@ charsets_provided(Req, State) ->
cowboy_http_req:parse_header('Accept-Charset', Req2),
case AcceptCharset of
undefined ->
set_content_type(Req3, State2#state{charset_a=hd(CP)});
set_content_type(Req3, State2#state{
charset_a=element(1, hd(CP))});
AcceptCharset ->
AcceptCharset2 = prioritize_charsets(AcceptCharset),
choose_charset(Req3, State2, AcceptCharset2)
Expand Down Expand Up @@ -397,10 +398,9 @@ 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|_Tail],
{Provided, _Quality}) ->
match_charset(Req, State, _Accept, [{Provided, _}|_], {Provided, _}) ->
set_content_type(Req, State#state{charset_a=Provided});
match_charset(Req, State, Accept, [_Provided|Tail], Charset) ->
match_charset(Req, State, Accept, [_|Tail], Charset) ->
match_charset(Req, State, Accept, Tail, Charset).

set_content_type(Req=#http_req{meta=Meta}, State=#state{
Expand Down

0 comments on commit 95ed134

Please sign in to comment.