| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'test_suite.dart'; // For TestUtils. | 9 import 'test_suite.dart'; // For TestUtils. |
| 10 // TODO(efortuna): Rewrite to not use the args library and simply take an | 10 // TODO(efortuna): Rewrite to not use the args library and simply take an |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 /// directory listing will be displayed. | 31 /// directory listing will be displayed. |
| 32 | 32 |
| 33 const PREFIX_BUILDDIR = 'root_build'; | 33 const PREFIX_BUILDDIR = 'root_build'; |
| 34 const PREFIX_DARTDIR = 'root_dart'; | 34 const PREFIX_DARTDIR = 'root_dart'; |
| 35 | 35 |
| 36 // TODO(kustermann,ricow): We could change this to the following scheme: | 36 // TODO(kustermann,ricow): We could change this to the following scheme: |
| 37 // http://host:port/root_packages/X -> $BuildDir/packages/X | 37 // http://host:port/root_packages/X -> $BuildDir/packages/X |
| 38 // Issue: 8368 | 38 // Issue: 8368 |
| 39 | 39 |
| 40 main(List<String> arguments) { | 40 main(List<String> arguments) { |
| 41 // This script is in [dart]/tools/testing/dart. |
| 42 TestUtils.setDartDirUri(Platform.script.resolve('../../..')); |
| 41 /** Convenience method for local testing. */ | 43 /** Convenience method for local testing. */ |
| 42 var parser = new ArgParser(); | 44 var parser = new ArgParser(); |
| 43 parser.addOption('port', abbr: 'p', | 45 parser.addOption('port', abbr: 'p', |
| 44 help: 'The main server port we wish to respond to requests.', | 46 help: 'The main server port we wish to respond to requests.', |
| 45 defaultsTo: '0'); | 47 defaultsTo: '0'); |
| 46 parser.addOption('crossOriginPort', abbr: 'c', | 48 parser.addOption('crossOriginPort', abbr: 'c', |
| 47 help: 'A different port that accepts request from the main server port.', | 49 help: 'A different port that accepts request from the main server port.', |
| 48 defaultsTo: '0'); | 50 defaultsTo: '0'); |
| 49 parser.addFlag('help', abbr: 'h', negatable: false, | 51 parser.addFlag('help', abbr: 'h', negatable: false, |
| 50 help: 'Print this usage information.'); | 52 help: 'Print this usage information.'); |
| 51 parser.addOption('build-directory', help: 'The build directory to use.'); | 53 parser.addOption('build-directory', help: 'The build directory to use.'); |
| 52 parser.addOption('network', help: 'The network interface to use.', | 54 parser.addOption('network', help: 'The network interface to use.', |
| 53 defaultsTo: '0.0.0.0'); | 55 defaultsTo: '0.0.0.0'); |
| 54 parser.addFlag('csp', help: 'Use Content Security Policy restrictions.', | 56 parser.addFlag('csp', help: 'Use Content Security Policy restrictions.', |
| 55 defaultsTo: false); | 57 defaultsTo: false); |
| 56 parser.addOption('runtime', help: 'The runtime we are using (for csp flags).', | 58 parser.addOption('runtime', help: 'The runtime we are using (for csp flags).', |
| 57 defaultsTo: 'none'); | 59 defaultsTo: 'none'); |
| 58 | 60 |
| 59 var args = parser.parse(arguments); | 61 var args = parser.parse(arguments); |
| 60 if (args['help']) { | 62 if (args['help']) { |
| 61 print(parser.getUsage()); | 63 print(parser.getUsage()); |
| 62 } else { | 64 } else { |
| 63 // Pretend we're running test.dart so that TestUtils doesn't get confused | |
| 64 // about the "current directory." This is only used if we're trying to run | |
| 65 // this file independently for local testing. | |
| 66 TestUtils.testScriptPath = new Path(Platform.script.path) | |
| 67 .directoryPath | |
| 68 .join(new Path('../../test.dart')) | |
| 69 .canonicalize() | |
| 70 .toNativePath(); | |
| 71 var servers = new TestingServers(new Path(args['build-directory']), | 65 var servers = new TestingServers(new Path(args['build-directory']), |
| 72 args['csp'], | 66 args['csp'], |
| 73 args['runtime']); | 67 args['runtime']); |
| 74 var port = int.parse(args['port']); | 68 var port = int.parse(args['port']); |
| 75 var crossOriginPort = int.parse(args['crossOriginPort']); | 69 var crossOriginPort = int.parse(args['crossOriginPort']); |
| 76 servers.startServers(args['network'], | 70 servers.startServers(args['network'], |
| 77 port: port, | 71 port: port, |
| 78 crossOriginPort: crossOriginPort).then((_) { | 72 crossOriginPort: crossOriginPort).then((_) { |
| 79 DebugLogger.info('Server listening on port ${servers.port}'); | 73 DebugLogger.info('Server listening on port ${servers.port}'); |
| 80 DebugLogger.info('Server listening on port ${servers.crossOriginPort}'); | 74 DebugLogger.info('Server listening on port ${servers.crossOriginPort}'); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 class _Entry implements Comparable { | 391 class _Entry implements Comparable { |
| 398 final String name; | 392 final String name; |
| 399 final String displayName; | 393 final String displayName; |
| 400 | 394 |
| 401 _Entry(this.name, this.displayName); | 395 _Entry(this.name, this.displayName); |
| 402 | 396 |
| 403 int compareTo(_Entry other) { | 397 int compareTo(_Entry other) { |
| 404 return name.compareTo(other.name); | 398 return name.compareTo(other.name); |
| 405 } | 399 } |
| 406 } | 400 } |
| OLD | NEW |