| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 _httpRequestStatusString = null; | 77 _httpRequestStatusString = null; |
| 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 is received. | 87 // Only create a ByteBuilder, if multiple chunks are received. |
| 88 var bufferOrBuilder; | 88 var bufferOrBuilder; |
| 89 response.listen( | 89 response.listen( |
| 90 (data) { | 90 (data) { |
| 91 if (bufferOrBuilder == null) { | 91 if (bufferOrBuilder == null) { |
| 92 bufferOrBuilder = data; | 92 bufferOrBuilder = data; |
| 93 } else { | 93 } else { |
| 94 if (bufferOrBuilder is! BytesBuilder) { | 94 if (bufferOrBuilder is! BytesBuilder) { |
| 95 bufferOrBuilder = new BytesBuilder() | 95 bufferOrBuilder = new BytesBuilder() |
| 96 ..add(bufferOrBuilder); | 96 ..add(bufferOrBuilder); |
| 97 } | 97 } |
| 98 bufferOrBuilder.add(data); | 98 bufferOrBuilder.add(data); |
| 99 } | 99 } |
| 100 }, | 100 }, |
| 101 onDone: () { | 101 onDone: () { |
| 102 var data = bufferOrBuilder; | 102 var data = bufferOrBuilder; |
| 103 if (data is BytesBuilder) data = data.takeBytes(); | 103 if (data is BytesBuilder) data = data.takeBytes(); |
| 104 _requestCompleted(data, response); | 104 _requestCompleted(data, response); |
| 105 // Close the client to stop any timers currently held alive. |
| 105 _client.close(); | 106 _client.close(); |
| 106 }, | 107 }, |
| 107 onError: _requestFailed); | 108 onError: _requestFailed); |
| 108 }).catchError((error) { | 109 }).catchError((error) { |
| 109 _requestFailed(error); | 110 _requestFailed(error); |
| 110 }); | 111 }); |
| 111 } catch (error) { | 112 } catch (error) { |
| 112 _requestFailed(error); | 113 _requestFailed(error); |
| 113 } | 114 } |
| 114 // TODO(floitsch): remove this line. It's just here to push an event on the | 115 // TODO(floitsch): remove this line. It's just here to push an event on the |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } else if (Platform.isWindows) { | 316 } else if (Platform.isWindows) { |
| 316 filename = '$name.dll'; | 317 filename = '$name.dll'; |
| 317 } else { | 318 } else { |
| 318 _logResolution( | 319 _logResolution( |
| 319 'Native extensions not supported on ${Platform.operatingSystem}'); | 320 'Native extensions not supported on ${Platform.operatingSystem}'); |
| 320 throw 'Native extensions not supported on ${Platform.operatingSystem}'; | 321 throw 'Native extensions not supported on ${Platform.operatingSystem}'; |
| 321 } | 322 } |
| 322 | 323 |
| 323 return [path, filename, name]; | 324 return [path, filename, name]; |
| 324 } | 325 } |
| OLD | NEW |