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 library dart.io; | 5 library dart.io; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import "dart:async"; | 8 import "dart:async"; |
9 import "dart:collection"; | 9 import "dart:collection"; |
10 import "dart:convert"; | 10 import "dart:convert"; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 headers._parseCookies().single.value); | 455 headers._parseCookies().single.value); |
456 } | 456 } |
457 | 457 |
458 void testHeaderLists() { | 458 void testHeaderLists() { |
459 HttpHeaders.GENERAL_HEADERS.forEach((x) => null); | 459 HttpHeaders.GENERAL_HEADERS.forEach((x) => null); |
460 HttpHeaders.ENTITY_HEADERS.forEach((x) => null); | 460 HttpHeaders.ENTITY_HEADERS.forEach((x) => null); |
461 HttpHeaders.RESPONSE_HEADERS.forEach((x) => null); | 461 HttpHeaders.RESPONSE_HEADERS.forEach((x) => null); |
462 HttpHeaders.REQUEST_HEADERS.forEach((x) => null); | 462 HttpHeaders.REQUEST_HEADERS.forEach((x) => null); |
463 } | 463 } |
464 | 464 |
465 void testInvalidField() { | |
Søren Gjesse
2014/07/04 09:24:54
testInvalidField -> testInvalidFieldName
Anders Johnsen
2014/07/04 11:03:50
Done.
| |
466 void test(String field) { | |
467 _HttpHeaders headers = new _HttpHeaders("1.1"); | |
468 Expect.throws(() => headers.add(field, "value"), | |
469 (e) => e is FormatException); | |
470 Expect.throws(() => headers.set(field, "value"), | |
471 (e) => e is FormatException); | |
472 Expect.throws(() => headers.remove(field, "value"), | |
473 (e) => e is FormatException); | |
474 Expect.throws(() => headers.removeAll(field), | |
475 (e) => e is FormatException); | |
476 } | |
477 test('\r'); | |
478 test('\n'); | |
479 test(','); | |
480 test('test\x00'); | |
481 } | |
482 | |
483 void testInvalidValue() { | |
Søren Gjesse
2014/07/04 09:24:54
testInvalidValue -> testInvalidFieldValue
Anders Johnsen
2014/07/04 11:03:50
Done.
| |
484 void test(value, {bool remove: true}) { | |
485 _HttpHeaders headers = new _HttpHeaders("1.1"); | |
486 Expect.throws(() => headers.add("field", value), | |
487 (e) => e is FormatException); | |
488 Expect.throws(() => headers.set("field", value), | |
489 (e) => e is FormatException); | |
490 if (remove) { | |
491 Expect.throws(() => headers.remove("field", value), | |
492 (e) => e is FormatException); | |
493 } | |
494 } | |
495 test('\r'); | |
496 test('\n'); | |
497 test('test\x00'); | |
498 // Test we handle other types correctly. | |
499 test(new StringBuffer('\x00'), remove: false); | |
500 } | |
501 | |
465 main() { | 502 main() { |
466 testMultiValue(); | 503 testMultiValue(); |
467 testDate(); | 504 testDate(); |
468 testExpires(); | 505 testExpires(); |
469 testIfModifiedSince(); | 506 testIfModifiedSince(); |
470 testHost(); | 507 testHost(); |
471 testEnumeration(); | 508 testEnumeration(); |
472 testHeaderValue(); | 509 testHeaderValue(); |
473 testContentType(); | 510 testContentType(); |
474 testContentTypeCache(); | 511 testContentTypeCache(); |
475 testCookie(); | 512 testCookie(); |
476 testInvalidCookie(); | 513 testInvalidCookie(); |
477 testHeaderLists(); | 514 testHeaderLists(); |
515 testInvalidField(); | |
516 testInvalidValue(); | |
478 } | 517 } |
OLD | NEW |