class Falcon::Adapters::Output
def self.wrap(status, headers, body)
@parameter headers [Protocol::HTTP::Headers] The response headers.
@parameter status [Integer] The response status.
Wraps an array into a buffered body.
def self.wrap(status, headers, body) # In no circumstance do we want this header propagating out: if length = headers.delete(CONTENT_LENGTH) # We don't really trust the user to provide the right length to the transport. length = Integer(length) end if body.is_a?(::Protocol::HTTP::Body::Readable) return body elsif status == 200 and body.respond_to?(:to_path) # Don't mangle partial responsese (206) return ::Protocol::HTTP::Body::File.open(body.to_path) elsif body.is_a?(Array) length ||= body.sum(&:bytesize) return self.new(body, length) else return self.new(body, length) end end