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

Unified Diff: tests/standalone/io/http_body_test.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_utils.dart ('k') | tests/standalone/io/url_encoding_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_body_test.dart
diff --git a/tests/standalone/io/http_body_test.dart b/tests/standalone/io/http_body_test.dart
index a6ea742d6f49725e123b9f588def45f1cb5d659b..113c7c184f594be7d8679bd68b5206b9a5e12f92 100644
--- a/tests/standalone/io/http_body_test.dart
+++ b/tests/standalone/io/http_body_test.dart
@@ -46,7 +46,7 @@ void testHttpClientResponseBody() {
Expect.fail("bad body type");
}
}, onError: (error) {
- if (!shouldFail) Expect.fail("Error unexpected");
+ if (!shouldFail) throw error;
})
.whenComplete(() {
client.close();
@@ -90,9 +90,10 @@ void testHttpServerRequestBody() {
List<int> content,
dynamic expectedBody,
String type,
- {bool shouldFail: false}) {
+ {bool shouldFail: false,
+ Encoding defaultEncoding: Encoding.UTF_8}) {
HttpServer.bind("127.0.0.1", 0).then((server) {
- server.transform(new HttpBodyHandler())
+ server.transform(new HttpBodyHandler(defaultEncoding: defaultEncoding))
.listen((body) {
if (shouldFail) Expect.fail("Error expected");
Expect.equals(type, body.type);
@@ -166,6 +167,7 @@ void testHttpServerRequestBody() {
});
});
}
+
test("text/plain", "body".codeUnits, "body", "text");
test("text/plain; charset=utf-8",
"body".codeUnits,
@@ -250,6 +252,22 @@ File content\r
{ 'b' : '平仮名',
'平=仮名' : '平仮名'},
"form");
+
+ test('application/x-www-form-urlencoded',
+ 'a=%F8+%26%23548%3B'.codeUnits,
+ { 'a' : '\u{FFFD}\u{0224}' },
+ "form");
+
+ test('application/x-www-form-urlencoded',
+ 'a=%F8+%26%23548%3B'.codeUnits,
+ { 'a' : 'ø Ȥ' },
+ "form",
+ defaultEncoding: Encoding.ISO_8859_1);
+
+ test('application/x-www-form-urlencoded',
+ 'a=%C3%B8+%C8%A4'.codeUnits,
+ { 'a' : 'ø Ȥ' },
+ "form");
}
void main() {
« no previous file with comments | « sdk/lib/io/http_utils.dart ('k') | tests/standalone/io/url_encoding_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698