Browse Source

Update server.dart and pubspec to Dart 1.0.

Anders Johnsen 11 years ago
parent
commit
2ac33e0310
2 changed files with 10 additions and 16 deletions
  1. 5 5
      dart/pubspec.yaml
  2. 5 11
      dart/server.dart

+ 5 - 5
dart/pubspec.yaml

@@ -1,8 +1,8 @@
 name: dartbenchmark
 description: A benchmark of dart
 dependencies:
-  args: 0.5.9
-  crypto: 0.5.13
-  mustache: 0.1.5
-  postgresql: 0.2.7
-  yaml: 0.5.7
+  args: 0.9.0
+  crypto: 0.9.0
+  mustache: 0.1.6
+  postgresql: 0.2.12
+  yaml: 0.9.0

+ 5 - 11
dart/server.dart

@@ -1,7 +1,6 @@
 import 'dart:async' show Future;
 import 'dart:io';
-import 'dart:utf';
-import 'dart:json' as json;
+import 'dart:convert';
 import 'dart:math' show Random;
 import 'package:args/args.dart' show ArgParser;
 import 'package:mustache/mustache.dart' as mustache;
@@ -13,12 +12,12 @@ import 'package:yaml/yaml.dart' as yaml;
 /// address and port for incoming connections is configurable via command line
 /// arguments, as is the number of database connections to be maintained in the
 /// connection pool.
-main() {
+main(args) {
   var parser = new ArgParser();
   parser.addOption('address', abbr: 'a', defaultsTo: '0.0.0.0');
   parser.addOption('port', abbr: 'p', defaultsTo: '8080');
   parser.addOption('dbconnections', abbr: 'd', defaultsTo: '256');
-  var arguments = parser.parse(new Options().arguments);
+  var arguments = parser.parse(args);
   _startServer(
       arguments['address'],
       int.parse(arguments['port']),
@@ -126,16 +125,11 @@ _parseInt(text) =>
 _sendResponse(request, statusCode, [ type, response ]) {
   request.response.statusCode = statusCode;
   request.response.headers.date = new DateTime.now();
-  //
-  // Prevent GZIP encoding, because it is disallowed in the rules for these
-  // benchmark tests.
-  //
-  request.response.headers.add(HttpHeaders.CONTENT_ENCODING, '');
   if (type != null) {
     request.response.headers.contentType = type;
   }
   if (response != null) {
-    var data = encodeUtf8(response);
+    var data = UTF8.encode(response);
     request.response.contentLength = data.length;
     request.response.add(data);
   } else {
@@ -151,7 +145,7 @@ _sendHtml(request, response) {
 
 /// Completes the given [request] by writing the [response] as JSON.
 _sendJson(request, response) {
-  _sendResponse(request, HttpStatus.OK, _TYPE_JSON, json.stringify(response));
+  _sendResponse(request, HttpStatus.OK, _TYPE_JSON, JSON.encode(response));
 }
 
 /// Completes the given [request] by writing the [response] as plain text.