| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 * * Using credentials is only useful for cross-origin requests. | 67 * * Using credentials is only useful for cross-origin requests. |
| 68 * * The `Access-Control-Allow-Origin` header of `url` cannot contain a wildca
rd (*). | 68 * * The `Access-Control-Allow-Origin` header of `url` cannot contain a wildca
rd (*). |
| 69 * * The `Access-Control-Allow-Credentials` header of `url` must be set to tru
e. | 69 * * The `Access-Control-Allow-Credentials` header of `url` must be set to tru
e. |
| 70 * * If `Access-Control-Expose-Headers` has not been set to true, only a subse
t of all the response headers will be returned when calling [getAllRequestHeader
s]. | 70 * * If `Access-Control-Expose-Headers` has not been set to true, only a subse
t of all the response headers will be returned when calling [getAllRequestHeader
s]. |
| 71 * | 71 * |
| 72 * See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access
_authentication). | 72 * See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access
_authentication). |
| 73 */ | 73 */ |
| 74 static Future<HttpRequest> request(String url, | 74 static Future<HttpRequest> request(String url, |
| 75 {String method, bool withCredentials, String responseType, sendData, | 75 {String method, bool withCredentials, String responseType, sendData, |
| 76 void onProgress(ProgressEvent e)}) { | 76 void onProgress(ProgressEvent e)}) { |
| 77 var completer = new Completer<String>(); | 77 var completer = new Completer<HttpRequest>(); |
| 78 | 78 |
| 79 var xhr = new HttpRequest(); | 79 var xhr = new HttpRequest(); |
| 80 if (method == null) { | 80 if (method == null) { |
| 81 method = 'GET'; | 81 method = 'GET'; |
| 82 } | 82 } |
| 83 xhr.open(method, url, true); | 83 xhr.open(method, url, true); |
| 84 | 84 |
| 85 if (withCredentials != null) { | 85 if (withCredentials != null) { |
| 86 xhr.withCredentials = withCredentials; | 86 xhr.withCredentials = withCredentials; |
| 87 } | 87 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 111 xhr.send(sendData); | 111 xhr.send(sendData); |
| 112 } else { | 112 } else { |
| 113 xhr.send(); | 113 xhr.send(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 return completer.future; | 116 return completer.future; |
| 117 } | 117 } |
| 118 | 118 |
| 119 $!MEMBERS | 119 $!MEMBERS |
| 120 } | 120 } |
| OLD | NEW |