Index: tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate |
diff --git a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate |
index a983e4f6964ec8ad5e85bec92b153873c27ed5ba..ccd909b70d91ea50f0f81897d685cff7ea3f5c64 100644 |
--- a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate |
+++ b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate |
@@ -30,39 +30,25 @@ part of $LIBRARYNAME; |
* * [Using XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest) |
*/ |
$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
- |
/** |
- * Creates a URL get request for the specified [url]. |
- * |
- * The server response must be a `text/` mime type for this request to |
- * succeed. |
- * |
- * This is similar to [request] but specialized for HTTP GET requests which |
- * return text content. |
- * |
- * See also: |
+ * Creates a URL get request for the specified `url`. |
* |
- * * [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 $CLASSNAME.get(String url, onComplete($CLASSNAME request)) => |
+ _HttpRequestUtils.get(url, onComplete, false); |
+ // 80 char issue for comments in lists: dartbug.com/7588. |
/** |
- * Creates a URL request for the specified [url]. |
+ * 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). |
* |
- * By default this will do an HTTP GET request, this can be overridden with |
- * [method]. |
+ * After completing the request, the object will call the user-provided |
+ * [onComplete] callback. |
* |
- * The Future is completed when the response is available. |
- * |
- * The [withCredentials] parameter specified that credentials such as a cookie |
- * (already) set in the header or |
- * [authorization headers](http://tools.ietf.org/html/rfc1945#section-10.2) |
- * should be specified for the request. 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 (*). |
@@ -71,50 +57,9 @@ $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
* |
* 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 $CLASSNAME.getWithCredentials(String url, |
+ onComplete($CLASSNAME request)) => |
+ _HttpRequestUtils.get(url, onComplete, true); |
$!MEMBERS |
} |