Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 12050010: Revert "Adding ease-of-use methods to HttpRequest." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tests/html/xhr_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 75e5a585770f5f1d53e83547938be0973f70dd57..234dcf18bccc51baae4c70dc7b8d4488a020a765 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -13577,35 +13577,25 @@ class HtmlOptionsCollection extends HtmlCollection {
*/
@DomName('XMLHttpRequest')
class HttpRequest extends EventTarget {
-
/**
- * 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 (*).
@@ -13614,50 +13604,9 @@ class HttpRequest extends EventTarget {
*
* 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);
HttpRequest.internal() : super.internal();
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tests/html/xhr_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698