blob: 736d401e73b9a52ce30a9c489fc1941fe196ce00 [file] [log] [blame]
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
class _HttpRequestUtils {
// Helper for factory HttpRequest.get
static HttpRequest get(String url,
onSuccess(HttpRequest request),
bool withCredentials) {
final request = new HttpRequest();
request.open('GET', url, true);
request.withCredentials = withCredentials;
// Status 0 is for local XHR request.
request.on.readyStateChange.add((e) {
if (request.readyState == HttpRequest.DONE &&
(request.status == 200 || request.status == 0)) {
onSuccess(request);
}
});
request.send();
return request;
}
}