class Sinatra::Response
def finish
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 header["Content-Length"].nil? && body.respond_to?(:to_ary) header["Content-Length"] = body.to_ary. inject(0) { |len, part| len + part.length }.to_s end [status.to_i, header.to_hash, body] end end