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

Unified Diff: sdk/lib/io/http_body.dart

Issue 15221002: Add optional defaultEncoding to HttpBodyHandler, as a way to override default encoding for 'applica… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « no previous file | sdk/lib/io/http_body_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_body.dart
diff --git a/sdk/lib/io/http_body.dart b/sdk/lib/io/http_body.dart
index 1ec6d175ed730474b4d5ad4d623331befa78ead3..b6e106bd1145281d03b304344496df986288ce0c 100644
--- a/sdk/lib/io/http_body.dart
+++ b/sdk/lib/io/http_body.dart
@@ -41,22 +41,38 @@ class HttpBodyHandler
implements StreamTransformer<HttpRequest, HttpRequestBody> {
var _transformer;
- HttpBodyHandler() : _transformer = new _HttpBodyHandlerTransformer();
+ /**
+ * Create a new [HttpBodyHandler] to be used with a [Stream]<[HttpRequest]>,
+ * e.g. a [HttpServer].
+ *
+ * If the page was served using different encoding than UTF-8, set
+ * [defaultEncoding] accordingly. This is required for parsing
+ * 'application/x-www-form-urlencoded' content correctly.
Søren Gjesse 2013/05/16 07:13:58 At some point we should expand this comment and ex
Anders Johnsen 2013/05/16 07:40:16 Yeah. This would be a nice cleanup along with the
+ */
+ HttpBodyHandler({Encoding defaultEncoding: Encoding.UTF_8})
+ : _transformer = new _HttpBodyHandlerTransformer(defaultEncoding);
/**
* Process and parse an incoming [HttpRequest]. The returned [HttpRequestBody]
* contains a [response] field for accessing the [HttpResponse].
+ *
+ * See [HttpBodyHandler] constructor for more info on [defaultEncoding].
*/
- static Future<HttpRequestBody> processRequest(HttpRequest request) {
- return _HttpBodyHandler.processRequest(request);
+ static Future<HttpRequestBody> processRequest(
+ HttpRequest request,
+ {Encoding defaultEncoding: Encoding.UTF_8}) {
+ return _HttpBodyHandler.processRequest(request, defaultEncoding);
}
/**
* Process and parse an incoming [HttpClientResponse].
+ *
+ * See [HttpBodyHandler] constructor for more info on [defaultEncoding].
*/
static Future<HttpClientResponseBody> processResponse(
- HttpClientResponse response) {
- return _HttpBodyHandler.processResponse(response);
+ HttpClientResponse response,
+ {Encoding defaultEncoding: Encoding.UTF_8}) {
+ return _HttpBodyHandler.processResponse(response, defaultEncoding);
}
Stream<HttpRequestBody> bind(Stream<HttpRequest> stream) {
« no previous file with comments | « no previous file | sdk/lib/io/http_body_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698