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 html; | 5 part of html; |
6 | 6 |
7 class _HttpRequestUtils { | 7 class _HttpRequestUtils { |
8 | 8 |
9 // Helper for factory HttpRequest.get | 9 // Helper for factory HttpRequest.get |
10 static HttpRequest get(String url, | 10 static HttpRequest get(String url, |
11 onComplete(HttpRequest request), | 11 onComplete(HttpRequest request), |
12 bool withCredentials) { | 12 bool withCredentials) { |
13 final request = new HttpRequest(); | 13 final request = new HttpRequest(); |
14 request.open('GET', url, true); | 14 request.open('GET', url, true); |
15 | 15 |
16 request.withCredentials = withCredentials; | 16 request.withCredentials = withCredentials; |
17 | 17 |
18 request.on.readyStateChange.add((e) { | 18 request.onReadyStateChange.listen((e) { |
19 if (request.readyState == HttpRequest.DONE) { | 19 if (request.readyState == HttpRequest.DONE) { |
20 onComplete(request); | 20 onComplete(request); |
21 } | 21 } |
22 }); | 22 }); |
23 | 23 |
24 request.send(); | 24 request.send(); |
25 | 25 |
26 return request; | 26 return request; |
27 } | 27 } |
28 } | 28 } |
OLD | NEW |