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

Unified Diff: tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate

Issue 26893008: Adding HttpRequest.responseHeaders (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tightening up some error edge cases Created 7 years, 2 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:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/xhr_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 533265e3caad727afe24d904b59b191f3f914ff9..524b92872ae34eafa3885bedcb54e4eaacc6f563 100644
--- a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
+++ b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
@@ -54,8 +54,8 @@ $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
/**
* Makes a server POST request with the specified data encoded as form data.
*
- * This is roughly the POST equivalent of getString. This method is similar
- * to sending a FormData object with broader browser support but limited to
+ * This is roughly the POST equivalent of getString. This method is similar
+ * to sending a FormData object with broader browser support but limited to
* String values.
*
* See also:
@@ -90,7 +90,7 @@ $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
* Creates and sends a URL request for the specified [url].
*
* By default `request` will perform an HTTP GET request, but a different
- * method (`POST`, `PUT`, `DELETE`, etc) can be used by specifying the
+ * method (`POST`, `PUT`, `DELETE`, etc) can be used by specifying the
* [method] parameter.
*
* The Future is completed when the response is available.
@@ -270,5 +270,41 @@ $if DART2JS
$endif
}
+ /**
+ * Returns all response headers as a key-value map.
+ *
+ * Multiple values for the same header key can be combined into one,
+ * separated by a comma and a space.
+ *
+ * See: http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
+ */
+ Map<String, String> get responseHeaders {
+ // from Closure's goog.net.Xhrio.getResponseHeaders.
+ var headers = <String, String>{};
+ var headersString = this.getAllResponseHeaders();
+ if (headersString == null) {
+ return headers;
+ }
+ var headersList = headersString.split('\r\n');
+ for (var header in headersList) {
+ if (header.isEmpty) {
+ continue;
+ }
+
+ var splitIdx = header.indexOf(': ');
+ if (splitIdx == -1) {
+ continue;
+ }
+ var key = header.substring(0, splitIdx).toLowerCase();
+ var value = header.substring(splitIdx + 2);
+ if (headers.containsKey(key)) {
+ headers[key] = '${headers[key]}, $value';
+ } else {
+ headers[key] = value;
+ }
+ }
+ return headers;
+ }
+
$!MEMBERS
}
« no previous file with comments | « tests/html/xhr_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698