| Class | Sinatra::Response |
| In: |
lib/sinatra/base.rb
|
| Parent: | Rack::Response |
The response object. See Rack::Response and Rack::ResponseHelpers for more info: rack.rubyforge.org/doc/classes/Rack/Response.html rack.rubyforge.org/doc/classes/Rack/Response/Helpers.html
# File lib/sinatra/base.rb, line 51
51: def finish
52: @body = block if block_given?
53: if [204, 304].include?(status.to_i)
54: header.delete "Content-Type"
55: [status.to_i, header.to_hash, []]
56: else
57: body = @body || []
58: body = [body] if body.respond_to? :to_str
59: if body.respond_to?(:to_ary)
60: header["Content-Length"] = body.to_ary.
61: inject(0) { |len, part| len + Rack::Utils.bytesize(part) }.to_s
62: end
63: [status.to_i, header.to_hash, body]
64: end
65: end