Class: Sinatra::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Sinatra::Response
- Defined in:
- lib/sinatra/base.rb
Overview
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
Instance Method Summary collapse
Instance Method Details
#finish ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/sinatra/base.rb', line 54 def finish @body = block if block_given? if [204, 304].include?(status.to_i) header.delete "Content-Type" [status.to_i, header.to_hash, []] else body = @body || [] body = [body] if body.respond_to? :to_str if body.respond_to?(:to_ary) header["Content-Length"] = body.to_ary. inject(0) { |len, part| len + Rack::Utils.bytesize(part) }.to_s end [status.to_i, header.to_hash, body] end end |