class Rack::Response

def initialize(body = nil, status = 200, headers = {})

instance and the value can be either a +String+ or +Array+ instance.
the Rack specification for response headers. The key must be a +String+
The +headers+ must be a +Hash+ of key-value header pairs which conform to

can provide any other valid status code.
The +status+ defaults to +200+ which is the "OK" HTTP status code. You

body) or +call+ (streaming body).
Rack response body, typically implementing one of +each+ (enumerable
Otherwise it is expected +body+ conforms to the normal requirements of a

initial contents of the buffer.
construct a buffered response object containing using that string as the
If the +body+ responds to +to_str+, assume it's a string-like object and

buffering.
If the +body+ is +nil+, construct an empty response object with internal

and +headers+.
Initialize the response object with the specified +body+, +status+
def initialize(body = nil, status = 200, headers = {})
  @status = status.to_i
  unless headers.is_a?(Hash)
    raise ArgumentError, "Headers must be a Hash!"
  end
  @headers = Headers.new
  # Convert headers input to a plain hash with lowercase keys.
  headers.each do |k, v|
    @headers[k] = v
  end
  @writer = self.method(:append)
  @block = nil
  # Keep track of whether we have expanded the user supplied body.
  if body.nil?
    @body = []
    @buffered = true
    # Body is unspecified - it may be a buffered response, or it may be a HEAD response.
    @length = nil
  elsif body.respond_to?(:to_str)
    @body = [body]
    @buffered = true
    @length = body.to_str.bytesize
  else
    @body = body
    @buffered = nil # undetermined as of yet.
    @length = nil
  end
  yield self if block_given?
end