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 'root_library'; happens here from C Code | 7 // import 'root_library'; happens here from C Code |
8 | 8 |
9 // The root library (aka the script) is imported into this library. The | 9 // The root library (aka the script) is imported into this library. The |
10 // standalone embedder uses this to lookup the main entrypoint in the | 10 // standalone embedder uses this to lookup the main entrypoint in the |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 _httpRequestStatusString = error.toString(); | 68 _httpRequestStatusString = error.toString(); |
69 _httpRequestResponse = null; | 69 _httpRequestResponse = null; |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 void _makeHttpRequest(String uri) { | 73 void _makeHttpRequest(String uri) { |
74 var _client = new HttpClient(); | 74 var _client = new HttpClient(); |
75 _httpRequestResponseCode = 0; | 75 _httpRequestResponseCode = 0; |
76 _httpRequestStatusString = null; | 76 _httpRequestStatusString = null; |
77 _httpRequestResponse = null; | 77 _httpRequestResponse = null; |
78 Uri requestUri = Uri.parse(uri); | 78 try { |
79 _client.getUrl(requestUri) | 79 Uri requestUri = Uri.parse(uri); |
80 .then((HttpClientRequest request) => request.close()) | 80 _client.getUrl(requestUri) |
81 .then((HttpClientResponse response) { | 81 .then((HttpClientRequest request) => request.close()) |
82 return response | 82 .then((HttpClientResponse response) { |
83 .fold(new BytesBuilder(), (b, d) => b..add(d)) | 83 return response |
84 .then((builder) { | 84 .fold(new BytesBuilder(), (b, d) => b..add(d)) |
85 _requestCompleted(builder.takeBytes(), response); | 85 .then((builder) { |
86 }); | 86 _requestCompleted(builder.takeBytes(), response); |
87 }).catchError((error) { | 87 }); |
88 _requestFailed(error); | 88 }).catchError((error) { |
89 }); | 89 _requestFailed(error); |
| 90 }); |
| 91 } catch (error) { |
| 92 _requestFailed(error); |
| 93 } |
90 } | 94 } |
91 | 95 |
92 | 96 |
93 // Are we running on Windows? | 97 // Are we running on Windows? |
94 var _isWindows = false; | 98 var _isWindows = false; |
95 var _workingWindowsDrivePrefix; | 99 var _workingWindowsDrivePrefix; |
96 // The current working directory | 100 // The current working directory |
97 var _workingDirectoryUri; | 101 var _workingDirectoryUri; |
98 // The URI that the entry point script was loaded from. Remembered so that | 102 // The URI that the entry point script was loaded from. Remembered so that |
99 // package imports can be resolved relative to it. | 103 // package imports can be resolved relative to it. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 262 |
259 throw "URIs using the 'package:' scheme should look like " | 263 throw "URIs using the 'package:' scheme should look like " |
260 "'$right', not '$wrong'."; | 264 "'$right', not '$wrong'."; |
261 } | 265 } |
262 | 266 |
263 var packageRoot = _packageRoot == null ? | 267 var packageRoot = _packageRoot == null ? |
264 _entryPointScript.resolve('packages/') : | 268 _entryPointScript.resolve('packages/') : |
265 _packageRoot; | 269 _packageRoot; |
266 return _filePathFromUri(packageRoot.resolve(uri.path).toString()); | 270 return _filePathFromUri(packageRoot.resolve(uri.path).toString()); |
267 } | 271 } |
OLD | NEW |