class Sinatra::ExtendedRack

def setup_close(env, status, header, body)

def setup_close(env, status, header, 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