aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-13 02:15:51 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-13 02:15:51 -0700
commit79b0b1a0ef926e91388e24bc77d3831f6d50b13d (patch)
tree1826e850a7d8913fa4f1e044c869ef1f767f9fe9 /actionpack
parent7e6c310b052f9521e48f37341d42f618e004d692 (diff)
downloadrails-79b0b1a0ef926e91388e24bc77d3831f6d50b13d.tar.gz
rails-79b0b1a0ef926e91388e24bc77d3831f6d50b13d.tar.bz2
rails-79b0b1a0ef926e91388e24bc77d3831f6d50b13d.zip
Extract Response#string_body?
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/response.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/response.rb b/actionpack/lib/action_controller/response.rb
index c69223dd69..febe4ccf29 100644
--- a/actionpack/lib/action_controller/response.rb
+++ b/actionpack/lib/action_controller/response.rb
@@ -210,7 +210,11 @@ module ActionController # :nodoc:
def nonempty_ok_response?
ok = !status || status.to_s[0..2] == '200'
- ok && !body_parts.respond_to?(:call) && body_parts.any?
+ ok && string_body?
+ end
+
+ def string_body?
+ !body_parts.respond_to?(:call) && body_parts.any? && body_parts.all? { |part| part.is_a?(String) }
end
def set_conditional_cache_control!
@@ -231,7 +235,7 @@ module ActionController # :nodoc:
headers.delete('Content-Length')
elsif length = headers['Content-Length']
headers['Content-Length'] = length.to_s
- elsif !body_parts.respond_to?(:call) && (!status || status.to_s[0..2] != '304')
+ elsif string_body? && (!status || status.to_s[0..2] != '304')
headers["Content-Length"] = Rack::Utils.bytesize(body).to_s
end
end