Sets the Content-Length header on responses with fixed-length bodies.
# File lib/rack/content_length.rb, line 13 13: def call(env) 14: status, headers, body = @app.call(env) 15: headers = HeaderHash.new(headers) 16: 17: if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) && 18: !headers['Content-Length'] && 19: !headers['Transfer-Encoding'] && 20: body.respond_to?(:to_ary) 21: 22: obody = body 23: body, length = [], 0 24: obody.each { |part| body << part; length += bytesize(part) } 25: obody.close if obody.respond_to?(:close) 26: 27: headers['Content-Length'] = length.to_s 28: end 29: 30: [status, headers, body] 31: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.