Chromium Code Reviews| 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 492fcc9a6ff7c944fe8e0e28e376f65fb9210219..0c08cde381685e3eefecfb96ac4531c4164421f4 100644 |
| --- a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate |
| +++ b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate |
| @@ -52,6 +52,40 @@ $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| } |
| /** |
| + * Makes a server POST request with the specified data encoded as form data. |
| + * |
| + * This is similar to sending a FormData object but with broader browser |
| + * support but only supports string values. |
|
Emily Fortuna
2013/08/05 19:43:45
one of the two "but"s should be removed/replaced i
blois
2013/08/05 19:50:49
Done.
|
| + * |
| + * See also: |
| + * |
| + * * [request] |
| + */ |
| + static Future<HttpRequest> postFormData(String url, Map<String, String> data, |
| + {bool withCredentials, String responseType, |
| + Map<String, String> requestHeaders, |
| + void onProgress(ProgressEvent e)}) { |
| + |
| + var parts = []; |
| + data.forEach((key, value) { |
| + parts.add('${Uri.encodeQueryComponent(key)}=' |
| + '${Uri.encodeQueryComponent(value)}'); |
| + }); |
| + var formData = parts.join('&'); |
| + |
| + if (requestHeaders == null) { |
| + requestHeaders = <String, String>{}; |
| + } |
| + requestHeaders.putIfAbsent('Content-Type', |
| + () => 'application/x-www-form-urlencoded; charset=UTF-8'); |
| + |
| + return request(url, method: 'POST', withCredentials: withCredentials, |
| + responseType: responseType, |
| + requestHeaders: requestHeaders, sendData: formData, |
| + onProgress: onProgress); |
| + } |
| + |
| + /** |
| * Creates a URL request for the specified [url]. |
| * |
| * By default this will do an HTTP GET request, this can be overridden with |