diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-11-23 23:52:25 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-11-23 23:52:25 +0000 |
commit | 7c7d58937b614350d2cd474c45ff188864f67505 (patch) | |
tree | bdaa34b40cb4457c2b61c795a6d0e5345e404233 /actionpack/lib/action_controller | |
parent | efd0bdd9eaf66a361b01739522794ec0c9453d15 (diff) | |
download | rails-7c7d58937b614350d2cd474c45ff188864f67505.tar.gz rails-7c7d58937b614350d2cd474c45ff188864f67505.tar.bz2 rails-7c7d58937b614350d2cd474c45ff188864f67505.zip |
Fixed that HEAD should return the proper Content-Length header (that is, actually use @body.size, not just 0) [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5622 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/cgi_process.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index 10a3f08b91..47de1956cc 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -171,7 +171,9 @@ end_msg end def out(output = $stdout) - convert_content_type!(@headers) + convert_content_type! + set_content_length! + output.binmode if output.respond_to?(:binmode) output.sync = false if output.respond_to?(:sync=) @@ -196,16 +198,22 @@ end_msg end private - def convert_content_type!(headers) - if header = headers.delete("Content-Type") - headers["type"] = header + def convert_content_type! + if content_type = @headers.delete("Content-Type") + @headers["type"] = content_type end - if header = headers.delete("Content-type") - headers["type"] = header + if content_type = @headers.delete("Content-type") + @headers["type"] = content_type end - if header = headers.delete("content-type") - headers["type"] = header + if content_type = @headers.delete("content-type") + @headers["type"] = content_type end end + + # 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! + @headers["Content-Length"] = @body.size unless @body.respond_to?(:call) + end end end |