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

Side by Side Diff: utils/pub/io.dart

Issue 11464015: Revert "Stop working around issue 6984." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Base files Created 8 years 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/http/test/utils.dart ('k') | utils/pub/oauth2.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 /** 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 } 659 }
660 660
661 if (environment != null) { 661 if (environment != null) {
662 options.environment = new Map.from(Platform.environment); 662 options.environment = new Map.from(Platform.environment);
663 environment.forEach((key, value) => options.environment[key] = value); 663 environment.forEach((key, value) => options.environment[key] = value);
664 } 664 }
665 665
666 return fn(executable, args, options); 666 return fn(executable, args, options);
667 } 667 }
668 668
669 /// Closes [response] while ignoring the body of [request]. Returns a Future
670 /// that completes once the response is closed.
671 ///
672 /// Due to issue 6984, it's necessary to drain the request body before closing
673 /// the response.
674 Future closeHttpResponse(HttpRequest request, HttpResponse response) {
675 // TODO(nweiz): remove this when issue 4061 is fixed.
676 var stackTrace;
677 try {
678 throw "";
679 } catch (_, localStackTrace) {
680 stackTrace = localStackTrace;
681 }
682
683 var completer = new Completer();
684 request.inputStream.onError = (e) =>
685 completer.completeException(e, stackTrace);
686 request.inputStream.onData = request.inputStream.read;
687 request.inputStream.onClosed = () {
688 response.outputStream.close();
689 completer.complete(null);
690 };
691 return completer.future;
692 }
693
669 /** 694 /**
670 * Wraps [input] to provide a timeout. If [input] completes before 695 * Wraps [input] to provide a timeout. If [input] completes before
671 * [milliseconds] have passed, then the return value completes in the same way. 696 * [milliseconds] have passed, then the return value completes in the same way.
672 * However, if [milliseconds] pass before [input] has completed, it completes 697 * However, if [milliseconds] pass before [input] has completed, it completes
673 * with a [TimeoutException] with [description] (which should be a fragment 698 * with a [TimeoutException] with [description] (which should be a fragment
674 * describing the action that timed out). 699 * describing the action that timed out).
675 * 700 *
676 * Note that timing out will not cancel the asynchronous operation behind 701 * Note that timing out will not cancel the asynchronous operation behind
677 * [input]. 702 * [input].
678 */ 703 */
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 return new Directory(entry); 1019 return new Directory(entry);
995 } 1020 }
996 1021
997 /** 1022 /**
998 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 1023 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
999 */ 1024 */
1000 Uri _getUri(uri) { 1025 Uri _getUri(uri) {
1001 if (uri is Uri) return uri; 1026 if (uri is Uri) return uri;
1002 return new Uri.fromString(uri); 1027 return new Uri.fromString(uri);
1003 } 1028 }
OLDNEW
« no previous file with comments | « pkg/http/test/utils.dart ('k') | utils/pub/oauth2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698