Index: sdk/lib/html/dart2js/html_dart2js.dart |
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart |
index c57a862b4e071e7a12b735452e72afdcd656a249..d63f67b263970b2a3a0f4e7e51efe6a7664d18cb 100644 |
--- a/sdk/lib/html/dart2js/html_dart2js.dart |
+++ b/sdk/lib/html/dart2js/html_dart2js.dart |
@@ -12623,35 +12623,25 @@ class HtmlOptionsCollection extends HtmlCollection native "*HTMLOptionsCollectio |
*/ |
@DomName('XMLHttpRequest') |
class HttpRequest extends EventTarget native "*XMLHttpRequest" { |
- |
/** |
- * Creates a URL get request for the specified [url]. |
- * |
- * The server response must be a `text/` mime type for this request to |
- * succeed. |
+ * Creates a URL get request for the specified `url`. |
* |
- * This is similar to [request] but specialized for HTTP GET requests which |
- * return text content. |
- * |
- * See also: |
- * |
- * * [request] |
+ * After completing the request, the object will call the user-provided |
+ * [onComplete] callback. |
*/ |
- static Future<String> getString(String url, |
- {bool withCredentials, void onProgress(ProgressEvent e)}) { |
- return request(url, withCredentials: withCredentials, |
- onProgress: onProgress).then((xhr) => xhr.responseText); |
- } |
+ factory HttpRequest.get(String url, onComplete(HttpRequest request)) => |
+ _HttpRequestUtils.get(url, onComplete, false); |
+ // 80 char issue for comments in lists: dartbug.com/7588. |
/** |
- * Creates a URL request for the specified [url]. |
- * |
- * By default this will do an HTTP GET request, this can be overridden with |
- * [method]. |
+ * Creates a URL GET request for the specified `url` with |
+ * credentials such a cookie (already) set in the header or |
+ * [authorization headers](http://tools.ietf.org/html/rfc1945#section-10.2). |
* |
- * The Future is completed when the response is available. |
+ * After completing the request, the object will call the user-provided |
+ * [onComplete] callback. |
* |
- * Details to keep in mind when using credentials: |
+ * A few other details to keep in mind when using credentials: |
* |
* * Using credentials is only useful for cross-origin requests. |
* * The `Access-Control-Allow-Origin` header of `url` cannot contain a wildcard (*). |
@@ -12660,50 +12650,9 @@ class HttpRequest extends EventTarget native "*XMLHttpRequest" { |
* |
* See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access_authentication). |
*/ |
- static Future<HttpRequest> request(String url, |
- {String method, bool withCredentials, String responseType, sendData, |
- void onProgress(ProgressEvent e)}) { |
- 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; |
- } |
- |
- if (onProgress != null) { |
- xhr.onProgress.listen(onProgress); |
- } |
- |
- 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; |
- } |
+ factory HttpRequest.getWithCredentials(String url, |
+ onComplete(HttpRequest request)) => |
+ _HttpRequestUtils.get(url, onComplete, true); |
@DomName('XMLHttpRequest.abort') |