method
call
v3.1.0 -
Show latest stable
- Class:
Rails::Rack::ContentLength
call(env)public
No documentation available.
# File railties/lib/rails/rack/content_length.rb, line 15
def call(env)
status, headers, body = @app.call(env)
headers = HeaderHash.new(headers)
if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) &&
!headers['Content-Length'] &&
!headers['Transfer-Encoding'] &&
!(@sendfile && headers[@sendfile])
old_body = body
body, length = [], 0
old_body.each do |part|
body << part
length += bytesize(part)
end
old_body.close if old_body.respond_to?(:close)
headers['Content-Length'] = length.to_s
end
[status, headers, body]
end