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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 */ | 78 */ |
79 static Future<HttpRequest> request(String url, | 79 static Future<HttpRequest> request(String url, |
80 {String method, bool withCredentials, String responseType, sendData, | 80 {String method, bool withCredentials, String responseType, sendData, |
81 void onProgress(ProgressEvent e)}) { | 81 void onProgress(ProgressEvent e)}) { |
82 var completer = new Completer<HttpRequest>(); | 82 var completer = new Completer<HttpRequest>(); |
83 | 83 |
84 var xhr = new HttpRequest(); | 84 var xhr = new HttpRequest(); |
85 if (method == null) { | 85 if (method == null) { |
86 method = 'GET'; | 86 method = 'GET'; |
87 } | 87 } |
88 xhr.open(method, url, async: true); | 88 xhr.open(method, url, true); |
89 | 89 |
90 if (withCredentials != null) { | 90 if (withCredentials != null) { |
91 xhr.withCredentials = withCredentials; | 91 xhr.withCredentials = withCredentials; |
92 } | 92 } |
93 | 93 |
94 if (responseType != null) { | 94 if (responseType != null) { |
95 xhr.responseType = responseType; | 95 xhr.responseType = responseType; |
96 } | 96 } |
97 | 97 |
98 if (onProgress != null) { | 98 if (onProgress != null) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 $if DART2JS | 141 $if DART2JS |
142 var xhr = new HttpRequest(); | 142 var xhr = new HttpRequest(); |
143 return JS('bool', '"onloadend" in #', xhr); | 143 return JS('bool', '"onloadend" in #', xhr); |
144 $else | 144 $else |
145 return true; | 145 return true; |
146 $endif | 146 $endif |
147 } | 147 } |
148 | 148 |
149 $!MEMBERS | 149 $!MEMBERS |
150 } | 150 } |
OLD | NEW |