aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/response.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-01-07 15:55:28 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2009-01-07 15:55:28 -0800
commit074414883cd39c24a6197f7450723c6fc60132d0 (patch)
treeb52a918efe174eeaa95155d20d6aa605f53c7618 /actionpack/lib/action_controller/response.rb
parent48963a55c7b4cbd06a66a4f9717801a7417acba9 (diff)
downloadrails-074414883cd39c24a6197f7450723c6fc60132d0.tar.gz
rails-074414883cd39c24a6197f7450723c6fc60132d0.tar.bz2
rails-074414883cd39c24a6197f7450723c6fc60132d0.zip
Remove Content-Length header from :no_content responses
Diffstat (limited to 'actionpack/lib/action_controller/response.rb')
-rw-r--r--actionpack/lib/action_controller/response.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/response.rb b/actionpack/lib/action_controller/response.rb
index 64319fe102..27860a6207 100644
--- a/actionpack/lib/action_controller/response.rb
+++ b/actionpack/lib/action_controller/response.rb
@@ -231,10 +231,13 @@ module ActionController # :nodoc:
# Don't set the Content-Length for block-based bodies as that would mean
# reading it all into memory. Not nice for, say, a 2GB streaming file.
def set_content_length!
- unless body.respond_to?(:call) || (status && status.to_s[0..2] == '304')
- self.headers["Content-Length"] ||= body.size
+ if status && status.to_s[0..2] == '204'
+ headers.delete('Content-Length')
+ elsif length = headers['Content-Length']
+ headers['Content-Length'] = length.to_s
+ elsif !body.respond_to?(:call) && (!status || status.to_s[0..2] != '304')
+ headers["Content-Length"] = body.size.to_s
end
- headers["Content-Length"] = headers["Content-Length"].to_s if headers["Content-Length"]
end
def convert_language!