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

Methods

body=   each   finish  

Public Instance methods

[Source]

    # File lib/sinatra/base.rb, line 66
66:     def body=(value)
67:       value = value.body while Rack::Response === value
68:       @body = String === value ? [value.to_str] : value
69:     end

[Source]

    # File lib/sinatra/base.rb, line 71
71:     def each
72:       block_given? ? super : enum_for(:each)
73:     end

[Source]

    # File lib/sinatra/base.rb, line 75
75:     def finish
76:       if status.to_i / 100 == 1
77:         headers.delete "Content-Length"
78:         headers.delete "Content-Type"
79:       elsif Array === body and not [204, 304].include?(status.to_i)
80:         headers["Content-Length"] = body.inject(0) { |l, p| l + Rack::Utils.bytesize(p) }.to_s
81:       end
82: 
83:       # Rack::Response#finish sometimes returns self as response body. We don't want that.
84:       status, headers, result = super
85:       result = body if result == self
86:       [status, headers, result]
87:     end

[Validate]