| 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 contentType = ContentType.parse( | 373 contentType = ContentType.parse( |
| 374 " text/html ; charset = utf-8 ; xxx=yyy "); | 374 " text/html ; charset = utf-8 ; xxx=yyy "); |
| 375 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); | 375 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); |
| 376 contentType = ContentType.parse( | 376 contentType = ContentType.parse( |
| 377 'text/html; charset=utf-8; xxx="yyy"'); | 377 'text/html; charset=utf-8; xxx="yyy"'); |
| 378 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); | 378 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); |
| 379 contentType = ContentType.parse( | 379 contentType = ContentType.parse( |
| 380 " text/html ; charset = utf-8 ; xxx=yyy "); | 380 " text/html ; charset = utf-8 ; xxx=yyy "); |
| 381 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); | 381 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); |
| 382 | 382 |
| 383 contentType = ContentType.parse("text/html; charset=;"); |
| 384 check(contentType, "text", "html", {"charset": null}); |
| 385 contentType = ContentType.parse("text/html; charset;"); |
| 386 check(contentType, "text", "html", {"charset": null}); |
| 387 |
| 383 // Test builtin content types. | 388 // Test builtin content types. |
| 384 check(ContentType.TEXT, "text", "plain", {"charset": "utf-8"}); | 389 check(ContentType.TEXT, "text", "plain", {"charset": "utf-8"}); |
| 385 check(ContentType.HTML, "text", "html", {"charset": "utf-8"}); | 390 check(ContentType.HTML, "text", "html", {"charset": "utf-8"}); |
| 386 check(ContentType.JSON, "application", "json", {"charset": "utf-8"}); | 391 check(ContentType.JSON, "application", "json", {"charset": "utf-8"}); |
| 387 check(ContentType.BINARY, "application", "octet-stream"); | 392 check(ContentType.BINARY, "application", "octet-stream"); |
| 388 } | 393 } |
| 389 | 394 |
| 395 void testKnownContentTypes() { |
| 396 // Well known content types used by the VM service. |
| 397 ContentType.parse('text/html; charset=UTF-8'); |
| 398 ContentType.parse('application/dart; charset=UTF-8'); |
| 399 ContentType.parse('application/javascript; charset=UTF-8'); |
| 400 ContentType.parse('text/css; charset=UTF-8'); |
| 401 ContentType.parse('image/gif'); |
| 402 ContentType.parse('image/png'); |
| 403 ContentType.parse('image/jpeg'); |
| 404 ContentType.parse('image/jpeg'); |
| 405 ContentType.parse('image/svg+xml'); |
| 406 ContentType.parse('text/plain'); |
| 407 } |
| 408 |
| 390 void testContentTypeCache() { | 409 void testContentTypeCache() { |
| 391 _HttpHeaders headers = new _HttpHeaders("1.1"); | 410 _HttpHeaders headers = new _HttpHeaders("1.1"); |
| 392 headers.set(HttpHeaders.CONTENT_TYPE, "text/html"); | 411 headers.set(HttpHeaders.CONTENT_TYPE, "text/html"); |
| 393 Expect.equals("text", headers.contentType.primaryType); | 412 Expect.equals("text", headers.contentType.primaryType); |
| 394 Expect.equals("html", headers.contentType.subType); | 413 Expect.equals("html", headers.contentType.subType); |
| 395 Expect.equals("text/html", headers.contentType.value); | 414 Expect.equals("text/html", headers.contentType.value); |
| 396 headers.set(HttpHeaders.CONTENT_TYPE, "text/plain; charset=utf-8"); | 415 headers.set(HttpHeaders.CONTENT_TYPE, "text/plain; charset=utf-8"); |
| 397 Expect.equals("text", headers.contentType.primaryType); | 416 Expect.equals("text", headers.contentType.primaryType); |
| 398 Expect.equals("plain", headers.contentType.subType); | 417 Expect.equals("plain", headers.contentType.subType); |
| 399 Expect.equals("text/plain", headers.contentType.value); | 418 Expect.equals("text/plain", headers.contentType.value); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 main() { | 582 main() { |
| 564 testMultiValue(); | 583 testMultiValue(); |
| 565 testDate(); | 584 testDate(); |
| 566 testExpires(); | 585 testExpires(); |
| 567 testIfModifiedSince(); | 586 testIfModifiedSince(); |
| 568 testHost(); | 587 testHost(); |
| 569 testTransferEncoding(); | 588 testTransferEncoding(); |
| 570 testEnumeration(); | 589 testEnumeration(); |
| 571 testHeaderValue(); | 590 testHeaderValue(); |
| 572 testContentType(); | 591 testContentType(); |
| 592 testKnownContentTypes(); |
| 573 testContentTypeCache(); | 593 testContentTypeCache(); |
| 574 testCookie(); | 594 testCookie(); |
| 575 testInvalidCookie(); | 595 testInvalidCookie(); |
| 576 testHeaderLists(); | 596 testHeaderLists(); |
| 577 testInvalidFieldName(); | 597 testInvalidFieldName(); |
| 578 testInvalidFieldValue(); | 598 testInvalidFieldValue(); |
| 579 testClear(); | 599 testClear(); |
| 580 } | 600 } |
| OLD | NEW |