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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:math'; | 7 import 'dart:math'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 --boundar\r | 272 --boundar\r |
273 --bounda\r | 273 --bounda\r |
274 --bound\r | 274 --bound\r |
275 --boun\r | 275 --boun\r |
276 --bou\r | 276 --bou\r |
277 --bo\r | 277 --bo\r |
278 --b\r\r\r\r | 278 --b\r\r\r\r |
279 --\r\r\r | 279 --\r\r\r |
280 -\r"""; | 280 -\r"""; |
281 testParse(message, "boundary", [headers, headers], [body1, body2]); | 281 testParse(message, "boundary", [headers, headers], [body1, body2]); |
282 } | |
283 | 282 |
284 void testParseInvalid() { | 283 // Without initial CRLF. |
285 String message; | |
286 | |
287 // Missing initial CRLF. One body part less. | |
288 message = """ | 284 message = """ |
289 --xxx\r | 285 --xxx\r |
290 \r | 286 \r |
291 \r | 287 \r |
292 Body 1\r | 288 Body 1\r |
293 --xxx\r | 289 --xxx\r |
294 \r | 290 \r |
295 \r | 291 \r |
296 Body2\r | 292 Body2\r |
297 --xxx--\r\n"""; | 293 --xxx--\r\n"""; |
298 testParse(message, "xxx", null, ["\r\nBody2"]); | 294 testParse(message, "xxx", null, ["\r\nBody 1", "\r\nBody2"]); |
| 295 } |
| 296 |
| 297 void testParseInvalid() { |
| 298 String message; |
299 | 299 |
300 // Missing end boundary. | 300 // Missing end boundary. |
301 message = """ | 301 message = """ |
302 \r | 302 \r |
303 --xxx\r | 303 --xxx\r |
304 \r | 304 \r |
305 \r | 305 \r |
306 Body 1\r | 306 Body 1\r |
307 --xxx\r | 307 --xxx\r |
308 \r | 308 \r |
309 \r | 309 \r |
310 Body2\r | 310 Body2\r |
311 --xxx\r\n"""; | 311 --xxx\r\n"""; |
312 testParse(message, "xxx", null, [null, null], true); | 312 testParse(message, "xxx", null, [null, null], true); |
313 } | 313 } |
314 | 314 |
315 void main() { | 315 void main() { |
316 testParseValid(); | 316 testParseValid(); |
317 testParseInvalid(); | 317 testParseInvalid(); |
318 } | 318 } |
OLD | NEW |