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

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

Issue 10913034: Fix pub to close connection to dartlang.org when it's done downloading (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated Created 8 years, 3 months 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 | « no previous file | no next file » | 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 */ 284 */
285 // TODO(rnystrom): Should this be async? 285 // TODO(rnystrom): Should this be async?
286 String getFullPath(entry) => new File(_getPath(entry)).fullPathSync(); 286 String getFullPath(entry) => new File(_getPath(entry)).fullPathSync();
287 287
288 /** 288 /**
289 * Opens an input stream for a HTTP GET request to [uri], which may be a 289 * Opens an input stream for a HTTP GET request to [uri], which may be a
290 * [String] or [Uri]. 290 * [String] or [Uri].
291 */ 291 */
292 InputStream httpGet(uri) { 292 InputStream httpGet(uri) {
293 var resultStream = new ListInputStream(); 293 var resultStream = new ListInputStream();
294 var connection = new HttpClient().getUrl(_getUri(uri)); 294 var client = new HttpClient();
295 var connection = client.getUrl(_getUri(uri));
295 296
296 // TODO(nweiz): propagate this error to the return value. See issue 3657. 297 // TODO(nweiz): propagate this error to the return value. See issue 3657.
297 connection.onError = (e) { throw e; }; 298 connection.onError = (e) { throw e; };
298 connection.onResponse = (response) { 299 connection.onResponse = (response) {
299 if (response.statusCode >= 400) { 300 if (response.statusCode >= 400) {
300 // TODO(nweiz): propagate this error to the return value. See issue 3657. 301 // TODO(nweiz): propagate this error to the return value. See issue 3657.
301 throw new Exception( 302 throw new Exception(
302 "HTTP request for $uri failed with status ${response.statusCode}"); 303 "HTTP request for $uri failed with status ${response.statusCode}");
303 } 304 }
304 305
305 pipeInputToInput(response.inputStream, resultStream); 306 pipeInputToInput(response.inputStream, resultStream, client.shutdown);
306 }; 307 };
307 308
308 return resultStream; 309 return resultStream;
309 } 310 }
310 311
311 /** 312 /**
312 * Takes all input from [source] and writes it to [sink]. 313 * Takes all input from [source] and writes it to [sink].
313 * 314 *
314 * [onClosed] is called when [source] is closed. 315 * [onClosed] is called when [source] is closed.
315 */ 316 */
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return new Directory(entry); 485 return new Directory(entry);
485 } 486 }
486 487
487 /** 488 /**
488 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 489 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
489 */ 490 */
490 Uri _getUri(uri) { 491 Uri _getUri(uri) {
491 if (uri is Uri) return uri; 492 if (uri is Uri) return uri;
492 return new Uri.fromString(uri); 493 return new Uri.fromString(uri);
493 } 494 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698