class Sinatra::Response

def finish

def finish
  result = body
  if drop_content_info?
    headers.delete "Content-Length"
    headers.delete "Content-Type"
  end
  if drop_body?
    close
    result = []
  end
  if calculate_content_length?
    # if some other code has already set Content-Length, don't muck with it
    # currently, this would be the static file-handler
    headers["Content-Length"] = body.inject(0) { |l, p| l + Rack::Utils.bytesize(p) }.to_s
  end
  [status.to_i, headers, result]
end