class Sinatra::ExtendedRack

def setup_close(env, status, headers, body)

def setup_close(env, status, headers, body)
  return unless body.respond_to? :close and env.include? 'async.close'
  env['async.close'].callback { body.close }
  env['async.close'].errback { body.close }
end