Chromium Code Reviews| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 } | 87 } |
| 88 | 88 |
| 89 if (responseType != null) { | 89 if (responseType != null) { |
| 90 xhr.responseType = responseType; | 90 xhr.responseType = responseType; |
| 91 } | 91 } |
| 92 | 92 |
| 93 if (onProgress != null) { | 93 if (onProgress != null) { |
| 94 xhr.onProgress.listen(onProgress); | 94 xhr.onProgress.listen(onProgress); |
| 95 } | 95 } |
| 96 | 96 |
| 97 xhr.onLoad.listen((e) { | 97 xhr.onReadyStateChange.listen((e) { |
| 98 if (xhr.status >= 200 && xhr.status < 300 || | 98 if (xhr.readyState == HttpRequest.DONE) { |
| 99 xhr.status == 304 ) { | 99 if (xhr.status >= 200 && xhr.status < 300 || |
| 100 completer.complete(xhr); | 100 xhr.status == 304 ) { |
|
Emily Fortuna
2013/02/07 20:53:44
This doesn't fix the problem described in dartbug.
| |
| 101 } else { | 101 completer.complete(xhr); |
| 102 completer.completeError(e); | 102 } else { |
| 103 completer.completeError(e); | |
| 104 } | |
| 103 } | 105 } |
| 104 }); | 106 }); |
| 105 | 107 |
| 106 xhr.onError.listen((e) { | 108 xhr.onError.listen((e) { |
| 107 completer.completeError(e); | 109 completer.completeError(e); |
| 108 }); | 110 }); |
| 109 | 111 |
| 110 if (sendData != null) { | 112 if (sendData != null) { |
| 111 xhr.send(sendData); | 113 xhr.send(sendData); |
| 112 } else { | 114 } else { |
| 113 xhr.send(); | 115 xhr.send(); |
| 114 } | 116 } |
| 115 | 117 |
| 116 return completer.future; | 118 return completer.future; |
| 117 } | 119 } |
| 118 | 120 |
| 119 $!MEMBERS | 121 $!MEMBERS |
| 120 } | 122 } |
| OLD | NEW |