diff options
author | José Valim <jose.valim@gmail.com> | 2011-04-20 21:54:19 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-04-20 21:54:19 +0200 |
commit | d31af44012a6ba3ac5dbec45417ae9bfb5454d8c (patch) | |
tree | 4a10bfd99de5dbc208f487fc2c0f09bf274b0dd9 /actionpack/lib/action_dispatch/http/response.rb | |
parent | 356dacbafc8590244d9da7d4d601f7064e461bc7 (diff) | |
download | rails-d31af44012a6ba3ac5dbec45417ae9bfb5454d8c.tar.gz rails-d31af44012a6ba3ac5dbec45417ae9bfb5454d8c.tar.bz2 rails-d31af44012a6ba3ac5dbec45417ae9bfb5454d8c.zip |
Fix tests on 1.8 by explicitly checking for strings (which also improves performance).
Diffstat (limited to 'actionpack/lib/action_dispatch/http/response.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 78ecf177be..1f4f3ac0da 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -118,7 +118,15 @@ module ActionDispatch # :nodoc: def body=(body) @blank = true if body == EMPTY - @body = body.respond_to?(:each) ? body : [body] + + # Explicitly check for strings. This is *wrong* theoretically + # but if we don't check this, the performance on string bodies + # is bad on Ruby 1.8 (because strings responds to each then). + @body = if body.respond_to?(:to_str) || !body.respond_to?(:each) + [body] + else + body + end end def body_parts |