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

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

Issue 11348285: Work around issue 6984. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 569 }
570 570
571 if (environment != null) { 571 if (environment != null) {
572 options.environment = new Map.from(Platform.environment); 572 options.environment = new Map.from(Platform.environment);
573 environment.forEach((key, value) => options.environment[key] = value); 573 environment.forEach((key, value) => options.environment[key] = value);
574 } 574 }
575 575
576 return fn(executable, args, options); 576 return fn(executable, args, options);
577 } 577 }
578 578
579 /// Closes [response] while ignoring the body of [request]. Returns a Future
580 /// that completes once the response is closed.
581 ///
582 /// Due to issue 6984, it's necessary to drain the request body before closing
583 /// the response.
584 Future closeHttpResponse(HttpRequest request, HttpResponse response) {
585 var completer = new Completer();
586 request.inputStream.onError = completer.completeException;
587 request.inputStream.onData = request.inputStream.read;
588 request.inputStream.onClosed = () {
589 response.outputStream.close();
590 completer.complete(null);
591 };
592 return completer.future;
593 }
594
579 /** 595 /**
580 * Wraps [input] to provide a timeout. If [input] completes before 596 * Wraps [input] to provide a timeout. If [input] completes before
581 * [milliseconds] have passed, then the return value completes in the same way. 597 * [milliseconds] have passed, then the return value completes in the same way.
582 * However, if [milliseconds] pass before [input] has completed, it completes 598 * However, if [milliseconds] pass before [input] has completed, it completes
583 * with a [TimeoutException] with [description] (which should be a fragment 599 * with a [TimeoutException] with [description] (which should be a fragment
584 * describing the action that timed out). 600 * describing the action that timed out).
585 * 601 *
586 * Note that timing out will not cancel the asynchronous operation behind 602 * Note that timing out will not cancel the asynchronous operation behind
587 * [input]. 603 * [input].
588 */ 604 */
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 return new Directory(entry); 909 return new Directory(entry);
894 } 910 }
895 911
896 /** 912 /**
897 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 913 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
898 */ 914 */
899 Uri _getUri(uri) { 915 Uri _getUri(uri) {
900 if (uri is Uri) return uri; 916 if (uri is Uri) return uri;
901 return new Uri.fromString(uri); 917 return new Uri.fromString(uri);
902 } 918 }
OLDNEW
« pkg/http/test/utils.dart ('K') | « 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