| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); | 318 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); |
| 319 contentType = ContentType.parse( | 319 contentType = ContentType.parse( |
| 320 " text/html ; charset = utf-8 ; xxx=yyy "); | 320 " text/html ; charset = utf-8 ; xxx=yyy "); |
| 321 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); | 321 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); |
| 322 contentType = ContentType.parse( | 322 contentType = ContentType.parse( |
| 323 'text/html; charset=utf-8; xxx="yyy"'); | 323 'text/html; charset=utf-8; xxx="yyy"'); |
| 324 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); | 324 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); |
| 325 contentType = ContentType.parse( | 325 contentType = ContentType.parse( |
| 326 " text/html ; charset = utf-8 ; xxx=yyy "); | 326 " text/html ; charset = utf-8 ; xxx=yyy "); |
| 327 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); | 327 check(contentType, "text", "html", {"charset": "utf-8", "xxx": "yyy"}); |
| 328 |
| 329 // Test builtin content types. |
| 330 check(ContentType.TEXT, "text", "plain", {"charset": "utf-8"}); |
| 331 check(ContentType.HTML, "text", "html", {"charset": "utf-8"}); |
| 332 check(ContentType.JSON, "application", "json", {"charset": "utf-8"}); |
| 333 check(ContentType.BINARY, "application", "octet-stream"); |
| 328 } | 334 } |
| 329 | 335 |
| 330 void testContentTypeCache() { | 336 void testContentTypeCache() { |
| 331 _HttpHeaders headers = new _HttpHeaders("1.1"); | 337 _HttpHeaders headers = new _HttpHeaders("1.1"); |
| 332 headers.set(HttpHeaders.CONTENT_TYPE, "text/html"); | 338 headers.set(HttpHeaders.CONTENT_TYPE, "text/html"); |
| 333 Expect.equals("text", headers.contentType.primaryType); | 339 Expect.equals("text", headers.contentType.primaryType); |
| 334 Expect.equals("html", headers.contentType.subType); | 340 Expect.equals("html", headers.contentType.subType); |
| 335 Expect.equals("text/html", headers.contentType.value); | 341 Expect.equals("text/html", headers.contentType.value); |
| 336 headers.set(HttpHeaders.CONTENT_TYPE, "text/plain; charset=utf-8"); | 342 headers.set(HttpHeaders.CONTENT_TYPE, "text/plain; charset=utf-8"); |
| 337 Expect.equals("text", headers.contentType.primaryType); | 343 Expect.equals("text", headers.contentType.primaryType); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 testIfModifiedSince(); | 465 testIfModifiedSince(); |
| 460 testHost(); | 466 testHost(); |
| 461 testEnumeration(); | 467 testEnumeration(); |
| 462 testHeaderValue(); | 468 testHeaderValue(); |
| 463 testContentType(); | 469 testContentType(); |
| 464 testContentTypeCache(); | 470 testContentTypeCache(); |
| 465 testCookie(); | 471 testCookie(); |
| 466 testInvalidCookie(); | 472 testInvalidCookie(); |
| 467 testHeaderLists(); | 473 testHeaderLists(); |
| 468 } | 474 } |
| OLD | NEW |