| 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 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A utility for retrieving data from a URL. | 8 * A utility for retrieving data from a URL. |
| 9 * | 9 * |
| 10 * HttpRequest can be used to obtain data from http, ftp, and file | 10 * HttpRequest can be used to obtain data from http, ftp, and file |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 xhr.onLoad.listen((e) { | 153 xhr.onLoad.listen((e) { |
| 154 // Note: file:// URIs have status of 0. | 154 // Note: file:// URIs have status of 0. |
| 155 if ((xhr.status >= 200 && xhr.status < 300) || | 155 if ((xhr.status >= 200 && xhr.status < 300) || |
| 156 xhr.status == 0 || xhr.status == 304) { | 156 xhr.status == 0 || xhr.status == 304) { |
| 157 completer.complete(xhr); | 157 completer.complete(xhr); |
| 158 } else { | 158 } else { |
| 159 completer.completeError(e); | 159 completer.completeError(e); |
| 160 } | 160 } |
| 161 }); | 161 }); |
| 162 | 162 |
| 163 xhr.onError.listen((e) { | 163 xhr.onError.listen(completer.completeError); |
| 164 completer.completeError(e); | |
| 165 }); | |
| 166 | 164 |
| 167 if (sendData != null) { | 165 if (sendData != null) { |
| 168 xhr.send(sendData); | 166 xhr.send(sendData); |
| 169 } else { | 167 } else { |
| 170 xhr.send(); | 168 xhr.send(); |
| 171 } | 169 } |
| 172 | 170 |
| 173 return completer.future; | 171 return completer.future; |
| 174 } | 172 } |
| 175 | 173 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } else { | 265 } else { |
| 268 JS('', '#.send()', xhr); | 266 JS('', '#.send()', xhr); |
| 269 } | 267 } |
| 270 | 268 |
| 271 return completer.future; | 269 return completer.future; |
| 272 $endif | 270 $endif |
| 273 } | 271 } |
| 274 | 272 |
| 275 $!MEMBERS | 273 $!MEMBERS |
| 276 } | 274 } |
| OLD | NEW |