anchor.diff:      request.response.headers.contentType = type;
     }
     if (response != null) {
  -    request.response.write(response);
  +    var data = encodeUtf8(response);
  +    request.response.contentLength = data.length;
  +    request.response.add(data);
  +  } else {
  +    request.response.contentLength = 0;
     }
     request.response.close();
   }
  
positive.code:   _sendJson(request, { 'message': 'Hello, World!' });
  }
  
  /// Responds with the database query test to the [request].
  _dbTest(request) {
    var queries = _parseInt(request.uri.queryParameters['queries']).clamp(1, 500);
    var worlds = new List<World>(queries);
    Future.wait(new List.generate(queries, (index) {
      return _connectionPool.connect().then((connection) {
        return connection.query(
                'SELECT id, randomNumber FROM world WHERE id = @id;',
                { 'id': _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1 })
            .toList()
            .then((rows) {
              //
              // The benchmark's constraints tell us there is exactly one row.
              //
              var row = rows[0];
              worlds[index] = new World(row[0], row[1]);
            })
            .whenComplete(() { connection.close(); });
      });
    }, growable: false)).then((_) { _sendJson(request, worlds); });
  }
  
  /// Responds with the fortunes test to the [request].
  _fortunesTest(request) {
    var fortunes = [];
    _connectionPool.connect().then((connection) {
      return connection.query('SELECT id, message FROM fortune;')
          .toList()
          .then((rows) {
            for (var row in rows) {
              fortunes.add(new Fortune(row[0], row[1]));
            }
          })
          .whenComplete(() { connection.close(); });
    }).then((_) {
      fortunes.add(new Fortune(0, 'Additional fortune added at request time.'));
      fortunes.sort();
      _sendHtml(request, _fortunesTemplate.renderString({
  
negative.code: }
  
  /// Responds with the updates test to the [request].
  _updatesTest(request) {
    var queries = _parseInt(request.uri.queryParameters['queries']).clamp(1, 500);
    Future.wait(new List.generate(queries, (_) {
      return _queryRandom()
          .then((world) {
            world.randomNumber = _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1;
            return _connectionPool.connect().then((connection) {
              return connection.execute(
                  'UPDATE world SET randomNumber = @randomNumber WHERE id = @id;',
                  { 'randomNumber': world.randomNumber, 'id': world.id })
                  .whenComplete(() { connection.close(); });
            }).then((_) => world);
          });
    }, growable: false))
        .then((worlds) => _sendJson(request, worlds));
  }
  
  /// Responds with the plaintext test to the [request].
  