also set charset for json

This commit is contained in:
Konstantin Haase 2011-06-05 09:45:58 +02:00
parent b391e7f1fe
commit 07c272d632
2 changed files with 3 additions and 1 deletions

View File

@ -1300,7 +1300,8 @@ module Sinatra
set :logging, false
set :method_override, false
set :default_encoding, "utf-8"
set :add_charset, [/^text\//, 'application/javascript', 'application/xml', 'application/xhtml+xml']
set :add_charset, %w[javascript xml xhtml+xml json].map { |t| "application/#{t}" }
settings.add_charset << /^text\//
# explicitly generating a session secret eagerly to play nice with preforking
begin

View File

@ -446,6 +446,7 @@ class HelpersTest < Test::Unit::TestCase
assert_equal content_type(:xml), 'application/xml;charset=utf-8'
assert_equal content_type(:xhtml), 'application/xhtml+xml;charset=utf-8'
assert_equal content_type(:js), 'application/javascript;charset=utf-8'
assert_equal content_type(:json), 'application/json;charset=utf-8'
assert_equal content_type(:bar), 'application/bar'
assert_equal content_type(:png), 'image/png'
assert_equal content_type(:baz), 'application/baz;charset=utf-8'