aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-07-21 19:00:52 +0200
committerLoïc Hoguin <[email protected]>2012-07-21 21:01:38 +0200
commit95ed1348c3ba6006c7bb9cf5025b79ab550901a0 (patch)
tree3e0ca7c9883a129fb31663ab58c32e2646261830 /src
parent86f9f481c8c8326380279df3cd2162163c1c40f0 (diff)
downloadcowboy-95ed1348c3ba6006c7bb9cf5025b79ab550901a0.tar.gz
cowboy-95ed1348c3ba6006c7bb9cf5025b79ab550901a0.tar.bz2
cowboy-95ed1348c3ba6006c7bb9cf5025b79ab550901a0.zip
REST: Fix charset matching
Diffstat (limited to 'src')
-rw-r--r--src/cowboy.app.src2
-rw-r--r--src/cowboy_http_rest.erl8
2 files changed, 5 insertions, 5 deletions
diff --git a/src/cowboy.app.src b/src/cowboy.app.src
index 544142b..46e5b95 100644
--- a/src/cowboy.app.src
+++ b/src/cowboy.app.src
@@ -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, [
diff --git a/src/cowboy_http_rest.erl b/src/cowboy_http_rest.erl
index 7f19c89..a0bcc13 100644
--- a/src/cowboy_http_rest.erl
+++ b/src/cowboy_http_rest.erl
@@ -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)
@@ -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{