| Index: sdk/lib/html/dartium/html_dartium.dart
|
| diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
|
| index 2cf25d8b4276f58330ca7074d74a8a4935b1e706..04a7c52950a4f4a00420119fe8e31c28696ae409 100644
|
| --- a/sdk/lib/html/dartium/html_dartium.dart
|
| +++ b/sdk/lib/html/dartium/html_dartium.dart
|
| @@ -13504,6 +13504,69 @@ class HttpRequest extends EventTarget {
|
| onComplete(HttpRequest request)) =>
|
| _HttpRequestUtils.get(url, onComplete, true);
|
|
|
| +
|
| + /**
|
| + * Creates a URL get request for the specified `url`.
|
| + *
|
| + * The server response must be a `text/` mime type for this request to
|
| + * succeed.
|
| + */
|
| + static Future<String> getString(String url,
|
| + {bool withCredentials}) {
|
| + return request(url, withCredentials: withCredentials).then(
|
| + (xhr) {
|
| + return xhr.responseText;
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Creates a URL request for the specified `url`.
|
| + *
|
| + * By default this will do an HTTP GET request, this can be overridden with
|
| + * [method].
|
| + *
|
| + * The Future is completed when the response is available.
|
| + */
|
| + static Future<HttpRequest> request(String url,
|
| + {String method, bool withCredentials, String responseType, sendData}) {
|
| + var completer = new Completer<String>();
|
| +
|
| + var xhr = new HttpRequest();
|
| + if (method == null) {
|
| + method = 'GET';
|
| + }
|
| + xhr.open(method, url, true);
|
| +
|
| + if (withCredentials != null) {
|
| + xhr.withCredentials = withCredentials;
|
| + }
|
| +
|
| + if (responseType != null) {
|
| + xhr.responseType = responseType;
|
| + }
|
| +
|
| + xhr.onLoad.listen((e) {
|
| + if (xhr.status >= 200 && xhr.status < 300 ||
|
| + xhr.status == 304 ) {
|
| + completer.complete(xhr);
|
| + } else {
|
| + completer.completeError(e);
|
| + }
|
| + });
|
| +
|
| + xhr.onError.listen((e) {
|
| + completer.completeError(e);
|
| + });
|
| +
|
| + if (sendData != null) {
|
| + xhr.send(sendData);
|
| + } else {
|
| + xhr.send();
|
| + }
|
| +
|
| + return completer.future;
|
| + }
|
| +
|
| HttpRequest.internal() : super.internal();
|
|
|
| @DomName('XMLHttpRequest.abort')
|
|
|