class Sinatra::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

Public Instance Methods

body=(value) click to toggle source
# File lib/sinatra/base.rb, line 66
def body=(value)
  value = value.body while Rack::Response === value
  @body = String === value ? [value.to_str] : value
end
each() click to toggle source
# File lib/sinatra/base.rb, line 71
def each
  block_given? ? super : enum_for(:each)
end
finish() click to toggle source
# File lib/sinatra/base.rb, line 75
def finish
  if status.to_i / 100 == 1
    headers.delete "Content-Length"
    headers.delete "Content-Type"
  elsif Array === body and not [204, 304].include?(status.to_i)
    headers["Content-Length"] = body.inject(0) { |l, p| l + Rack::Utils.bytesize(p) }.to_s
  end

  # Rack::Response#finish sometimes returns self as response body. We don't want that.
  status, headers, result = super
  result = body if result == self
  [status, headers, result]
end