| 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 /** | 5 /** |
| 6 * Helper functionality to make working with IO easier. | 6 * Helper functionality to make working with IO easier. |
| 7 */ | 7 */ |
| 8 #library('io'); | 8 #library('io'); |
| 9 | 9 |
| 10 #import('dart:io'); | 10 #import('dart:io'); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 } | 377 } |
| 378 | 378 |
| 379 client.shutdown(); | 379 client.shutdown(); |
| 380 completer.completeException(e); | 380 completer.completeException(e); |
| 381 }; | 381 }; |
| 382 | 382 |
| 383 connection.onResponse = (response) { | 383 connection.onResponse = (response) { |
| 384 if (response.statusCode >= 400) { | 384 if (response.statusCode >= 400) { |
| 385 client.shutdown(); | 385 client.shutdown(); |
| 386 completer.completeException( | 386 completer.completeException( |
| 387 new HttpException(response.statusCode, response.reasonPhrase)); | 387 new PubHttpException(response.statusCode, response.reasonPhrase)); |
| 388 return; | 388 return; |
| 389 } | 389 } |
| 390 | 390 |
| 391 completer.complete(response.inputStream); | 391 completer.complete(response.inputStream); |
| 392 }; | 392 }; |
| 393 | 393 |
| 394 return completer.future; | 394 return completer.future; |
| 395 } | 395 } |
| 396 | 396 |
| 397 /** | 397 /** |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 tarProcess.onExit = completer.complete; | 648 tarProcess.onExit = completer.complete; |
| 649 gzipProcess.onError = completer.completeException; | 649 gzipProcess.onError = completer.completeException; |
| 650 gzipProcess.onError = completer.completeException; | 650 gzipProcess.onError = completer.completeException; |
| 651 | 651 |
| 652 return completer.future.transform((exitCode) => exitCode == 0); | 652 return completer.future.transform((exitCode) => exitCode == 0); |
| 653 } | 653 } |
| 654 | 654 |
| 655 /** | 655 /** |
| 656 * Exception thrown when an HTTP operation fails. | 656 * Exception thrown when an HTTP operation fails. |
| 657 */ | 657 */ |
| 658 class HttpException implements Exception { | 658 class PubHttpException implements Exception { |
| 659 final int statusCode; | 659 final int statusCode; |
| 660 final String reason; | 660 final String reason; |
| 661 | 661 |
| 662 const HttpException(this.statusCode, this.reason); | 662 const PubHttpException(this.statusCode, this.reason); |
| 663 } | 663 } |
| 664 | 664 |
| 665 /** | 665 /** |
| 666 * Exception thrown when an operation times out. | 666 * Exception thrown when an operation times out. |
| 667 */ | 667 */ |
| 668 class TimeoutException implements Exception { | 668 class TimeoutException implements Exception { |
| 669 final String message; | 669 final String message; |
| 670 | 670 |
| 671 const TimeoutException(this.message); | 671 const TimeoutException(this.message); |
| 672 } | 672 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 return new Directory(entry); | 705 return new Directory(entry); |
| 706 } | 706 } |
| 707 | 707 |
| 708 /** | 708 /** |
| 709 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 709 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 710 */ | 710 */ |
| 711 Uri _getUri(uri) { | 711 Uri _getUri(uri) { |
| 712 if (uri is Uri) return uri; | 712 if (uri is Uri) return uri; |
| 713 return new Uri.fromString(uri); | 713 return new Uri.fromString(uri); |
| 714 } | 714 } |
| OLD | NEW |