Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Unified Diff: pkg/intl/test/web_server.dart

Issue 11035027: Add in-process http server to the dart test scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address more comments. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/intl/test/web_server.dart
diff --git a/pkg/intl/test/web_server.dart b/pkg/intl/test/web_server.dart
deleted file mode 100644
index 987489f0726cfdbabb2105b13003a33909df53da..0000000000000000000000000000000000000000
--- a/pkg/intl/test/web_server.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/**
- * This file runs a trivial HTTP server to serve locale data files from the
- * intl/lib/src/data directory. The code is primarily copied from the dart:io
- * example at http://www.dartlang.org/articles/io/
- */
-
-#import('dart:io');
-#import('dart:isolate');
-
-var server = new HttpServer();
-
-_send404(HttpResponse response) {
- response.statusCode = HttpStatus.NOT_FOUND;
- response.outputStream.close();
-}
-
-startServer(String basePath) {
- server.listen('127.0.0.1', 8000);
- server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
- var path = request.path;
- if (path == '/terminate') {
- server.close();
- return;
- }
- final File file = new File('${basePath}${path}');
- file.exists().then((bool found) {
- if (found) {
- // Set the CORS header to allow us to issue requests to localhost when
- // the HTML was opened from a file.
- response.headers.set("Access-Control-Allow-Origin", "*");
- file.fullPath().then((String fullPath) {
- file.openInputStream().pipe(response.outputStream);
- });
- } else {
- _send404(response);
- }
- });
- };
-}
-
-main() {
- // Compute base path for the request based on the location of the
- // script and then start the server.
- File script = new File(new Options().script);
- script.directory().then((Directory d) {
- startServer('${d.path}/../lib/src/data');
- });
- // After 60 seconds, if we haven't already been told to terminate, shut down
- // the server, at which point the program exits.
- new Timer(60000, (t) {server.close();});
-}
« no previous file with comments | « pkg/intl/test/start_web_server.dart ('k') | pkg/pkg.status » ('j') | tools/test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698