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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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.onLoad.listen((e) { |
| 98 if (xhr.status >= 200 && xhr.status < 300 || | 98 // Note: file:// URIs have status of 0. |
| 99 xhr.status == 304 ) { | 99 if ((xhr.status >= 200 && xhr.status < 300) || |
| 100 xhr.status == 0 || xhr.status == 304) { | |
|
Emily Fortuna
2013/02/07 20:55:50
note -- please add in the comments of this method
| |
| 100 completer.complete(xhr); | 101 completer.complete(xhr); |
| 101 } else { | 102 } else { |
| 102 completer.completeError(e); | 103 completer.completeError(e); |
|
Siggi Cherem (dart-lang)
2013/02/07 21:03:30
not for this CL, but we should also consider wheth
| |
| 103 } | 104 } |
| 104 }); | 105 }); |
| 105 | 106 |
| 106 xhr.onError.listen((e) { | 107 xhr.onError.listen((e) { |
| 107 completer.completeError(e); | 108 completer.completeError(e); |
| 108 }); | 109 }); |
| 109 | 110 |
| 110 if (sendData != null) { | 111 if (sendData != null) { |
| 111 xhr.send(sendData); | 112 xhr.send(sendData); |
| 112 } else { | 113 } else { |
| 113 xhr.send(); | 114 xhr.send(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 return completer.future; | 117 return completer.future; |
| 117 } | 118 } |
| 118 | 119 |
| 119 $!MEMBERS | 120 $!MEMBERS |
| 120 } | 121 } |
| OLD | NEW |