| 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 builtin; | 5 library builtin; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 // import 'root_library'; happens here from C Code | 8 // import 'root_library'; happens here from C Code |
| 9 | 9 |
| 10 // The root library (aka the script) is imported into this library. The | 10 // The root library (aka the script) is imported into this library. The |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 _httpRequestResponse = null; | 78 _httpRequestResponse = null; |
| 79 try { | 79 try { |
| 80 Uri requestUri = Uri.parse(uri); | 80 Uri requestUri = Uri.parse(uri); |
| 81 _client.getUrl(requestUri) | 81 _client.getUrl(requestUri) |
| 82 .then((HttpClientRequest request) => request.close()) | 82 .then((HttpClientRequest request) => request.close()) |
| 83 .then((HttpClientResponse response) { | 83 .then((HttpClientResponse response) { |
| 84 return response | 84 return response |
| 85 .fold(new BytesBuilder(), (b, d) => b..add(d)) | 85 .fold(new BytesBuilder(), (b, d) => b..add(d)) |
| 86 .then((builder) { | 86 .then((builder) { |
| 87 _requestCompleted(builder.takeBytes(), response); | 87 _requestCompleted(builder.takeBytes(), response); |
| 88 // This client is only used for a single request. Force closing |
| 89 // it now otherwise we wait around until it times out. |
| 90 _client.close(force:true); |
| 88 }); | 91 }); |
| 89 }).catchError((error) { | 92 }).catchError((error) { |
| 90 _requestFailed(error); | 93 _requestFailed(error); |
| 91 }); | 94 }); |
| 92 } catch (error) { | 95 } catch (error) { |
| 93 _requestFailed(error); | 96 _requestFailed(error); |
| 94 } | 97 } |
| 95 // TODO(floitsch): remove this line. It's just here to push an event on the | 98 // TODO(floitsch): remove this line. It's just here to push an event on the |
| 96 // event loop so that we invoke the scheduled microtasks. Also remove the | 99 // event loop so that we invoke the scheduled microtasks. Also remove the |
| 97 // import of dart:async when this line is not needed anymore. | 100 // import of dart:async when this line is not needed anymore. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 270 |
| 268 throw "URIs using the 'package:' scheme should look like " | 271 throw "URIs using the 'package:' scheme should look like " |
| 269 "'$right', not '$wrong'."; | 272 "'$right', not '$wrong'."; |
| 270 } | 273 } |
| 271 | 274 |
| 272 var packageRoot = _packageRoot == null ? | 275 var packageRoot = _packageRoot == null ? |
| 273 _entryPointScript.resolve('packages/') : | 276 _entryPointScript.resolve('packages/') : |
| 274 _packageRoot; | 277 _packageRoot; |
| 275 return _filePathFromUri(packageRoot.resolve(uri.path).toString()); | 278 return _filePathFromUri(packageRoot.resolve(uri.path).toString()); |
| 276 } | 279 } |
| OLD | NEW |