OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:math'; | 6 import 'dart:math'; |
7 | 7 |
8 import "package:unittest/unittest.dart"; | 8 import "package:unittest/unittest.dart"; |
9 import "package:mime/mime.dart"; | 9 import "package:mime/mime.dart"; |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 expect(Future.wait([ | 62 expect(Future.wait([ |
63 testWrite(data), | 63 testWrite(data), |
64 testWrite(data, 10), | 64 testWrite(data, 10), |
65 testWrite(data, 2), | 65 testWrite(data, 2), |
66 testWrite(data, 1)]), | 66 testWrite(data, 1)]), |
67 completes); | 67 completes); |
68 }); | 68 }); |
69 } | 69 } |
70 | 70 |
71 void _testParseValid() { | 71 void _testParseValid() { |
| 72 // Empty message from Chrome form post. |
| 73 var message = '------WebKitFormBoundaryU3FBruSkJKG0Yor1--\r\n'; |
| 74 _testParse(message, "----WebKitFormBoundaryU3FBruSkJKG0Yor1", [], []); |
| 75 |
72 // Sample from Wikipedia. | 76 // Sample from Wikipedia. |
73 var message = """ | 77 message = """ |
74 This is a message with multiple parts in MIME format.\r | 78 This is a message with multiple parts in MIME format.\r |
75 --frontier\r | 79 --frontier\r |
76 Content-Type: text/plain\r | 80 Content-Type: text/plain\r |
77 \r | 81 \r |
78 This is the body of the message.\r | 82 This is the body of the message.\r |
79 --frontier\r | 83 --frontier\r |
80 Content-Type: application/octet-stream\r | 84 Content-Type: application/octet-stream\r |
81 Content-Transfer-Encoding: base64\r | 85 Content-Transfer-Encoding: base64\r |
82 \r | 86 \r |
83 PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg | 87 PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 \r | 305 \r |
302 Body2\r | 306 Body2\r |
303 --xxx\r\n"""; | 307 --xxx\r\n"""; |
304 _testParse(message, "xxx", null, [null, null], true); | 308 _testParse(message, "xxx", null, [null, null], true); |
305 } | 309 } |
306 | 310 |
307 void main() { | 311 void main() { |
308 _testParseValid(); | 312 _testParseValid(); |
309 _testParseInvalid(); | 313 _testParseInvalid(); |
310 } | 314 } |
OLD | NEW |