Index: utils/tests/pub/test_pub.dart |
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart |
index 8ce622361e5bdc66954545fe5c32b4d2c23a963e..e0ea168d7168948a65ca696be1ddb05f0b41a5b7 100644 |
--- a/utils/tests/pub/test_pub.dart |
+++ b/utils/tests/pub/test_pub.dart |
@@ -52,15 +52,8 @@ TarFileDescriptor tar(Pattern name, [List<Descriptor> contents]) => |
new TarFileDescriptor(name, contents); |
/** |
- * The current [HttpServer] created using [serve]. |
- */ |
-var _server; |
- |
-/** |
* Creates an HTTP server to serve [contents] as static files. This server will |
* exist only for the duration of the pub run. |
- * |
- * Subsequent calls to [serve] will replace the previous server. |
*/ |
void serve(String host, int port, [List<Descriptor> contents]) { |
var baseDir = dir("serve-dir", contents); |
@@ -69,9 +62,8 @@ void serve(String host, int port, [List<Descriptor> contents]) { |
} |
_schedule((_) { |
- if (_server != null) _server.close(); |
- _server = new HttpServer(); |
- _server.defaultRequestHandler = (request, response) { |
+ var server = new HttpServer(); |
+ server.defaultRequestHandler = (request, response) { |
var path = request.uri.replaceFirst("/", "").split("/"); |
response.persistentConnection = false; |
var stream; |
@@ -99,11 +91,8 @@ void serve(String host, int port, [List<Descriptor> contents]) { |
response.outputStream.close(); |
}); |
}; |
- _server.listen(host, port); |
- _scheduleCleanup((_) { |
- if (_server != null) _server.close(); |
- _server = null; |
- }); |
+ server.listen(host, port); |
+ _scheduleCleanup((_) => server.close()); |
return new Future.immediate(null); |
}); |