Permalink
Browse files

also set charset for json

  • Loading branch information...
1 parent b391e7f commit 07c272d6320a7c3cb99bb4b76ea69a5ada376b9d @rkh rkh committed Jun 5, 2011
Showing with 3 additions and 1 deletion.
  1. +2 −1 lib/sinatra/base.rb
  2. +1 −0 test/helpers_test.rb
View
@@ -1300,7 +1300,8 @@ def self.force_encoding(data, *) data end
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
@@ -446,6 +446,7 @@ def test_default
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'

0 comments on commit 07c272d

Please sign in to comment.