| OLD | NEW |
| 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 | 6 |
| 7 #import('dart:io'); | 7 import 'dart:io'; |
| 8 #import('dart:isolate'); | 8 import 'dart:isolate'; |
| 9 #import('test_suite.dart'); // For TestUtils. | 9 import 'test_suite.dart'; // For TestUtils. |
| 10 | 10 |
| 11 HttpServer _httpServer; | 11 HttpServer _httpServer; |
| 12 | 12 |
| 13 void startHttpServer(String host, int port) { | 13 void startHttpServer(String host, int port) { |
| 14 var basePath = TestUtils.dartDir(); | 14 var basePath = TestUtils.dartDir(); |
| 15 _httpServer = new HttpServer(); | 15 _httpServer = new HttpServer(); |
| 16 _httpServer.onError = (e) { | 16 _httpServer.onError = (e) { |
| 17 // Consider errors in the builtin http server fatal. | 17 // Consider errors in the builtin http server fatal. |
| 18 // Intead of just throwing the exception we print | 18 // Intead of just throwing the exception we print |
| 19 // a message that makes it clearer what happened. | 19 // a message that makes it clearer what happened. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 41 }); | 41 }); |
| 42 } | 42 } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 _httpServer.listen(host, port); | 45 _httpServer.listen(host, port); |
| 46 } | 46 } |
| 47 | 47 |
| 48 terminateHttpServer() { | 48 terminateHttpServer() { |
| 49 if (_httpServer != null) _httpServer.close(); | 49 if (_httpServer != null) _httpServer.close(); |
| 50 } | 50 } |
| OLD | NEW |