mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
also set charset for json
This commit is contained in:
parent
b391e7f1fe
commit
07c272d632
2 changed files with 3 additions and 1 deletions
|
@ -1300,7 +1300,8 @@ module Sinatra
|
||||||
set :logging, false
|
set :logging, false
|
||||||
set :method_override, false
|
set :method_override, false
|
||||||
set :default_encoding, "utf-8"
|
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
|
# explicitly generating a session secret eagerly to play nice with preforking
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -446,6 +446,7 @@ class HelpersTest < Test::Unit::TestCase
|
||||||
assert_equal content_type(:xml), 'application/xml;charset=utf-8'
|
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(:xhtml), 'application/xhtml+xml;charset=utf-8'
|
||||||
assert_equal content_type(:js), 'application/javascript;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(:bar), 'application/bar'
|
||||||
assert_equal content_type(:png), 'image/png'
|
assert_equal content_type(:png), 'image/png'
|
||||||
assert_equal content_type(:baz), 'application/baz;charset=utf-8'
|
assert_equal content_type(:baz), 'application/baz;charset=utf-8'
|
||||||
|
|
Loading…
Add table
Reference in a new issue