Permalink
Browse files

Extract Response#string_body?

  • Loading branch information...
jeremy committed Mar 13, 2009
1 parent 7e6c310 commit 79b0b1a0ef926e91388e24bc77d3831f6d50b13d
Showing with 6 additions and 2 deletions.
  1. +6 −2 actionpack/lib/action_controller/response.rb
@@ -210,7 +210,11 @@ def handle_conditional_get!
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 @@ def set_content_length!
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

0 comments on commit 79b0b1a

Please sign in to comment.