mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 13:10:24 +00:00
REST: Fix charset matching
This commit is contained in:
parent
86f9f481c8
commit
95ed1348c3
2 changed files with 5 additions and 5 deletions
|
@ -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, [
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue