diff options
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 6 | ||||
-rw-r--r-- | actionpack/test/dispatch/response_test.rb | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index fc840668d5..5797c63924 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -111,9 +111,9 @@ module ActionDispatch # :nodoc: end def body - str = '' - each { |part| str << part.to_s } - str + strings = [] + each { |part| strings << part.to_s } + strings.join end EMPTY = " " diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 337ece6b88..9bdd5ecbc6 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -5,6 +5,15 @@ class ResponseTest < ActiveSupport::TestCase @response = ActionDispatch::Response.new end + def test_response_body_encoding + # FIXME: remove this conditional on Rails 4.0 + return unless "<3".encoding_aware? + + body = ["hello".encode('utf-8')] + response = ActionDispatch::Response.new 200, {}, body + assert_equal Encoding::UTF_8, response.body.encoding + end + test "simple output" do @response.body = "Hello, World!" |