Permalink
Browse files

use Array#join so that file encoding doesn't impact returned string.

Fixes #3957
  • Loading branch information...
1 parent 25ac7e4 commit 4371be2125e974a6938d42f0ce47dd8af42c9a27 @tenderlove tenderlove committed Dec 13, 2011
Showing with 12 additions and 3 deletions.
  1. +3 −3 actionpack/lib/action_dispatch/http/response.rb
  2. +9 −0 actionpack/test/dispatch/response_test.rb
View
6 actionpack/lib/action_dispatch/http/response.rb
@@ -108,9 +108,9 @@ def to_path
end
def body
- str = ''
- each { |part| str << part.to_s }
- str
+ strings = []
+ each { |part| strings << part.to_s }
+ strings.join
end
EMPTY = " "
View
9 actionpack/test/dispatch/response_test.rb
@@ -5,6 +5,15 @@ def setup
@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!"

0 comments on commit 4371be2

Please sign in to comment.