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

Unified Diff: sdk/lib/io/http_body_impl.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: Rebase 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 | « sdk/lib/io/http_body.dart ('k') | sdk/lib/io/http_utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_body_impl.dart
diff --git a/sdk/lib/io/http_body_impl.dart b/sdk/lib/io/http_body_impl.dart
index 736e86e7e785246012a47b7e2a2e0083b777a416..c8d90d7eef647bd1077b1a8a8f30021b2bd4a8ca 100644
--- a/sdk/lib/io/http_body_impl.dart
+++ b/sdk/lib/io/http_body_impl.dart
@@ -6,15 +6,20 @@ part of dart.io;
class _HttpBodyHandlerTransformer
extends StreamEventTransformer<HttpRequest, HttpRequestBody> {
+ final Encoding _defaultEncoding;
+ _HttpBodyHandlerTransformer(this._defaultEncoding);
+
void handleData(HttpRequest request, EventSink<HttpRequestBody> sink) {
- HttpBodyHandler.processRequest(request)
+ _HttpBodyHandler.processRequest(request, _defaultEncoding)
.then(sink.add, onError: sink.addError);
}
}
class _HttpBodyHandler {
- static Future<HttpRequestBody> processRequest(HttpRequest request) {
- return process(request, request.headers)
+ static Future<HttpRequestBody> processRequest(
+ HttpRequest request,
+ Encoding defaultEncoding) {
+ return process(request, request.headers, defaultEncoding)
.then((body) => new _HttpRequestBody(request, body),
onError: (error) {
// Try to send BAD_REQUEST response.
@@ -26,13 +31,15 @@ class _HttpBodyHandler {
}
static Future<HttpClientResponseBody> processResponse(
- HttpClientResponse response) {
- return process(response, response.headers)
+ HttpClientResponse response,
+ Encoding defaultEncoding) {
+ return process(response, response.headers, defaultEncoding)
.then((body) => new _HttpClientResponseBody(response, body));
}
static Future<HttpBody> process(Stream<List<int>> stream,
- HttpHeaders headers) {
+ HttpHeaders headers,
+ Encoding defaultEncoding) {
ContentType contentType = headers.contentType;
Future<HttpBody> asBinary() {
@@ -113,11 +120,11 @@ class _HttpBodyHandler {
case "x-www-form-urlencoded":
return asText(Encoding.ASCII)
.then((body) {
- var map = _HttpUtils.splitQueryString(body.body);
+ var map = _HttpUtils.splitQueryString(
+ body.body, encoding: defaultEncoding);
var result = {};
String parse(String s) {
- return _HttpUtils.decodeHttpEntityString(
- _HttpUtils.decodeUrlEncodedString(s));
+ return _HttpUtils.decodeHttpEntityString(s);
}
for (var key in map.keys) {
result[parse(key)] = parse(map[key]);
« no previous file with comments | « sdk/lib/io/http_body.dart ('k') | sdk/lib/io/http_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698