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

Side by Side Diff: utils/testrunner/http_server.dart

Issue 11103015: Added the ability for testrunner to start the HTTP server with a random port and communicate that p… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/unittest.dart ('k') | utils/testrunner/options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library http_server; 5 library http_server;
6 import 'dart:io'; 6 import 'dart:io';
7 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 8
9 /** An options parser for the server. */ 9 /** An options parser for the server. */
10 ArgParser getOptionParser() { 10 ArgParser getOptionParser() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 'csv' : 'text/csv', 44 'csv' : 'text/csv',
45 'htm' : 'text/html', 45 'htm' : 'text/html',
46 'html' : 'text/html', 46 'html' : 'text/html',
47 'txt' : 'text/plain', 47 'txt' : 'text/plain',
48 'rtf' : 'text/rtf', 48 'rtf' : 'text/rtf',
49 'mp4' : 'video/mp4', 49 'mp4' : 'video/mp4',
50 'qt' : 'video/quicktime', 50 'qt' : 'video/quicktime',
51 'vc1' : 'video/vc1' 51 'vc1' : 'video/vc1'
52 }; 52 };
53 53
54 HttpTestServer(port, this.staticFileDirectory) { 54 HttpTestServer(int port, this.staticFileDirectory) {
55 server = new HttpServer(); 55 server = new HttpServer();
56 server.listen("127.0.0.1", port); 56 try {
57 server.listen("127.0.0.1", port);
58 print('Server listening on port $port');
59 } catch (e) {
60 print('Server listen on port $port failed');
61 throw e;
62 }
57 server.onError = (e) { 63 server.onError = (e) {
58 }; 64 };
59 server.defaultRequestHandler = 65 server.defaultRequestHandler =
60 (HttpRequest request, HttpResponse response) { 66 (HttpRequest request, HttpResponse response) {
61 try { 67 try {
62 if (staticFileDirectory != null) { 68 if (staticFileDirectory != null) {
63 String fname = request.path; 69 String fname = request.path;
64 String path = '$staticFileDirectory$fname'; 70 String path = '$staticFileDirectory$fname';
65 File f = new File(path); 71 File f = new File(path);
66 if (f.existsSync()) { 72 if (f.existsSync()) {
(...skipping 26 matching lines...) Expand all
93 server.addRequestHandler(matcher, handler); 99 server.addRequestHandler(matcher, handler);
94 } else { 100 } else {
95 server.addRequestHandler(matcher, handler.onRequest); 101 server.addRequestHandler(matcher, handler.onRequest);
96 } 102 }
97 } 103 }
98 104
99 void close() { 105 void close() {
100 server.close(); 106 server.close();
101 } 107 }
102 } 108 }
OLDNEW
« no previous file with comments | « pkg/unittest/unittest.dart ('k') | utils/testrunner/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698