diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-12 19:45:16 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-12 19:45:16 -0800 |
commit | 810837dda890a5bc5d0b4d65b973ca0ccc9465bd (patch) | |
tree | a540e2b9ac0bd28bec68e5c0c2d3207e818a5a9d | |
parent | 3d4f913f77f447e2a09415355249116d5e9d07d1 (diff) | |
download | rails-810837dda890a5bc5d0b4d65b973ca0ccc9465bd.tar.gz rails-810837dda890a5bc5d0b4d65b973ca0ccc9465bd.tar.bz2 rails-810837dda890a5bc5d0b4d65b973ca0ccc9465bd.zip |
use Array#join so that file encoding doesn't impact returned string.
Fixes #3957
-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!" |