Chromium Code Reviews| Index: pkg/http_server/test/http_multipart_test.dart |
| diff --git a/pkg/http_server/test/http_multipart_test.dart b/pkg/http_server/test/http_multipart_test.dart |
| index f7e5cbb4c9a7abd2f9c926055ca5e207b745b430..5a8803550ce6582365490f77a2d1cf5cb19680b8 100644 |
| --- a/pkg/http_server/test/http_multipart_test.dart |
| +++ b/pkg/http_server/test/http_multipart_test.dart |
| @@ -40,14 +40,15 @@ class FormField { |
| void postDataTest(List<int> message, |
| String contentType, |
| String boundary, |
| - List<FormField> expectedFields) { |
| + List<FormField> expectedFields, |
| + {defaultEncoding: LATIN1}) { |
| HttpServer.bind("127.0.0.1", 0).then((server) { |
| server.listen((request) { |
| String boundary = request.headers.contentType.parameters['boundary']; |
| request |
| .transform(new MimeMultipartTransformer(boundary)) |
| .map((part) => HttpMultipartFormData.parse( |
| - part, defaultEncoding: LATIN1)) |
| + part, defaultEncoding: defaultEncoding)) |
| .map((multipart) { |
| var future; |
| if (multipart.isText) { |
| @@ -186,6 +187,9 @@ Content of file\r |
| contentType: 'application/octet-stream', |
| filename: 'VERSION')]); |
| + // In Chrome, Safari and Firefox HTML entity encoding might be used for |
| + // values in form fields. The HTML entity encoding for ひらがな is |
| + // ひらがな |
| message = [ |
| 45, 45, 45, 45, 45, 45, 87, 101, 98, 75, 105, 116, 70, 111, 114, 109, 66, |
| 111, 117, 110, 100, 97, 114, 121, 118, 65, 86, 122, 117, 103, 75, 77, 116, |
| @@ -201,7 +205,28 @@ Content of file\r |
| postDataTest(message, |
| 'multipart/form-data', |
| '----WebKitFormBoundaryvAVzugKMtZbyWoBG', |
| - [new FormField('name', 'ひらがな')]); |
| + [new FormField('name', 'ひらがな')], |
| + defaultEncoding: UTF8); |
| + |
| + // The UTF-8 encoding of ひらがな is |
| + // [227, 129, 178, 227, 130, 137, 227, 129, 140, 227, 129, 170]. |
| + message = [ |
| + 45, 45, 45, 45, 45, 45, 87, 101, 98, 75, 105, 116, 70, 111, 114, 109, 66, |
| + 111, 117, 110, 100, 97, 114, 121, 71, 88, 116, 66, 114, 99, 106, 120, 104, |
| + 101, 75, 101, 78, 54, 105, 48, 13, 10, 67, 111, 110, 116, 101, 110, 116, |
| + 45, 68, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 58, 32, 102, |
| + 111, 114, 109, 45, 100, 97, 116, 97, 59, 32, 110, 97, 109, 101, 61, 34, |
| + 116, 101, 115, 116, 34, 13, 10, 13, 10, 227, 129, 178, 227, 130, 137, 227, |
| + 129, 140, 227, 129, 170, 13, 10, 45, 45, 45, 45, 45, 45, 87, 101, 98, 75, |
| + 105, 116, 70, 111, 114, 109, 66, 111, 117, 110, 100, 97, 114, 121, 71, 88, |
| + 116, 66, 114, 99, 106, 120, 104, 101, 75, 101, 78, 54, 105, 48, 45, 45, 13, |
|
kustermann
2014/11/18 16:34:20
long line
Søren Gjesse
2014/11/19 07:41:05
Done.
|
| + 10]; |
| + |
| + postDataTest(message, |
| + 'multipart/form-data', |
| + '----WebKitFormBoundaryGXtBrcjxheKeN6i0', |
| + [new FormField('test', 'ひらがな')], |
| + defaultEncoding: UTF8); |
| message = [ |
| 45, 45, 45, 45, 45, 45, 87, 101, 98, 75, 105, 116, 70, 111, 114, 109, 66, |