instance method
set_content_length!
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v2.3.18 PrivateSignature
set_content_length!()
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.
Source
# File actionpack/lib/action_controller/response.rb, line 218
def set_content_length!
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.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
end
end
Defined in actionpack/lib/action_controller/response.rb line 218
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Response