| 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) { | 82 .then((HttpClientRequest request) { |
| 83 request.persistentConnection = false; | 83 request.persistentConnection = false; |
| 84 return request.close(); | 84 return request.close(); |
| 85 }) | 85 }) |
| 86 .then((HttpClientResponse response) { | 86 .then((HttpClientResponse response) { |
| 87 // Only create a ByteBuilder, if multiple chunks are received. | 87 // Only create a ByteBuilder, if multiple chunks are received. |
| 88 var bufferOrBuilder; | 88 var builder = new BytesBuilder(copy: false); |
| 89 response.listen( | 89 response.listen( |
| 90 (data) { | 90 builder.add, |
| 91 if (bufferOrBuilder == null) { | |
| 92 bufferOrBuilder = data; | |
| 93 } else { | |
| 94 if (bufferOrBuilder is! BytesBuilder) { | |
| 95 bufferOrBuilder = new BytesBuilder() | |
| 96 ..add(bufferOrBuilder); | |
| 97 } | |
| 98 bufferOrBuilder.add(data); | |
| 99 } | |
| 100 }, | |
| 101 onDone: () { | 91 onDone: () { |
| 102 var data = bufferOrBuilder; | 92 _requestCompleted(builder.takeBytes(), response); |
| 103 if (data is BytesBuilder) data = data.takeBytes(); | |
| 104 _requestCompleted(data, response); | |
| 105 // Close the client to stop any timers currently held alive. | 93 // Close the client to stop any timers currently held alive. |
| 106 _client.close(); | 94 _client.close(); |
| 107 }, | 95 }, |
| 108 onError: _requestFailed); | 96 onError: _requestFailed); |
| 109 }).catchError((error) { | 97 }).catchError((error) { |
| 110 _requestFailed(error); | 98 _requestFailed(error); |
| 111 }); | 99 }); |
| 112 } catch (error) { | 100 } catch (error) { |
| 113 _requestFailed(error); | 101 _requestFailed(error); |
| 114 } | 102 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } else if (Platform.isWindows) { | 304 } else if (Platform.isWindows) { |
| 317 filename = '$name.dll'; | 305 filename = '$name.dll'; |
| 318 } else { | 306 } else { |
| 319 _logResolution( | 307 _logResolution( |
| 320 'Native extensions not supported on ${Platform.operatingSystem}'); | 308 'Native extensions not supported on ${Platform.operatingSystem}'); |
| 321 throw 'Native extensions not supported on ${Platform.operatingSystem}'; | 309 throw 'Native extensions not supported on ${Platform.operatingSystem}'; |
| 322 } | 310 } |
| 323 | 311 |
| 324 return [path, filename, name]; | 312 return [path, filename, name]; |
| 325 } | 313 } |
| OLD | NEW |