| 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 | 8 |
| 9 part "../../../sdk/lib/io/io_sink.dart"; | 9 part "../../../sdk/lib/io/io_sink.dart"; |
| 10 part "../../../sdk/lib/io/http.dart"; | 10 part "../../../sdk/lib/io/http.dart"; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 Expect.equals(1, headers[HttpHeaders.PRAGMA].length); | 45 Expect.equals(1, headers[HttpHeaders.PRAGMA].length); |
| 46 | 46 |
| 47 headers.set(HttpHeaders.PRAGMA, ["pragma6", "pragma7"]); | 47 headers.set(HttpHeaders.PRAGMA, ["pragma6", "pragma7"]); |
| 48 Expect.equals(2, headers[HttpHeaders.PRAGMA].length); | 48 Expect.equals(2, headers[HttpHeaders.PRAGMA].length); |
| 49 | 49 |
| 50 headers.removeAll(HttpHeaders.PRAGMA); | 50 headers.removeAll(HttpHeaders.PRAGMA); |
| 51 Expect.isNull(headers[HttpHeaders.PRAGMA]); | 51 Expect.isNull(headers[HttpHeaders.PRAGMA]); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void testDate() { | 54 void testDate() { |
| 55 DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0); | 55 DateTime date1 = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0); |
| 56 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; | 56 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; |
| 57 DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0); | 57 DateTime date2 = new DateTime.utc(2000, DateTime.AUGUST, 16, 12, 34, 56, 0); |
| 58 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; | 58 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; |
| 59 | 59 |
| 60 _HttpHeaders headers = new _HttpHeaders("1.1"); | 60 _HttpHeaders headers = new _HttpHeaders("1.1"); |
| 61 Expect.isNull(headers.date); | 61 Expect.isNull(headers.date); |
| 62 headers.date = date1; | 62 headers.date = date1; |
| 63 Expect.equals(date1, headers.date); | 63 Expect.equals(date1, headers.date); |
| 64 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); | 64 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); |
| 65 Expect.equals(1, headers[HttpHeaders.DATE].length); | 65 Expect.equals(1, headers[HttpHeaders.DATE].length); |
| 66 headers.add(HttpHeaders.DATE, httpDate2); | 66 headers.add(HttpHeaders.DATE, httpDate2); |
| 67 Expect.equals(1, headers[HttpHeaders.DATE].length); | 67 Expect.equals(1, headers[HttpHeaders.DATE].length); |
| 68 Expect.equals(date2, headers.date); | 68 Expect.equals(date2, headers.date); |
| 69 Expect.equals(httpDate2, headers.value(HttpHeaders.DATE)); | 69 Expect.equals(httpDate2, headers.value(HttpHeaders.DATE)); |
| 70 headers.set(HttpHeaders.DATE, httpDate1); | 70 headers.set(HttpHeaders.DATE, httpDate1); |
| 71 Expect.equals(1, headers[HttpHeaders.DATE].length); | 71 Expect.equals(1, headers[HttpHeaders.DATE].length); |
| 72 Expect.equals(date1, headers.date); | 72 Expect.equals(date1, headers.date); |
| 73 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); | 73 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); |
| 74 | 74 |
| 75 headers.set(HttpHeaders.DATE, "xxx"); | 75 headers.set(HttpHeaders.DATE, "xxx"); |
| 76 Expect.equals("xxx", headers.value(HttpHeaders.DATE)); | 76 Expect.equals("xxx", headers.value(HttpHeaders.DATE)); |
| 77 Expect.equals(null, headers.date); | 77 Expect.equals(null, headers.date); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void testExpires() { | 80 void testExpires() { |
| 81 DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0); | 81 DateTime date1 = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0); |
| 82 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; | 82 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; |
| 83 DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0); | 83 DateTime date2 = new DateTime.utc(2000, DateTime.AUGUST, 16, 12, 34, 56, 0); |
| 84 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; | 84 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; |
| 85 | 85 |
| 86 _HttpHeaders headers = new _HttpHeaders("1.1"); | 86 _HttpHeaders headers = new _HttpHeaders("1.1"); |
| 87 Expect.isNull(headers.expires); | 87 Expect.isNull(headers.expires); |
| 88 headers.expires = date1; | 88 headers.expires = date1; |
| 89 Expect.equals(date1, headers.expires); | 89 Expect.equals(date1, headers.expires); |
| 90 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); | 90 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); |
| 91 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); | 91 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); |
| 92 headers.add(HttpHeaders.EXPIRES, httpDate2); | 92 headers.add(HttpHeaders.EXPIRES, httpDate2); |
| 93 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); | 93 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); |
| 94 Expect.equals(date2, headers.expires); | 94 Expect.equals(date2, headers.expires); |
| 95 Expect.equals(httpDate2, headers.value(HttpHeaders.EXPIRES)); | 95 Expect.equals(httpDate2, headers.value(HttpHeaders.EXPIRES)); |
| 96 headers.set(HttpHeaders.EXPIRES, httpDate1); | 96 headers.set(HttpHeaders.EXPIRES, httpDate1); |
| 97 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); | 97 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); |
| 98 Expect.equals(date1, headers.expires); | 98 Expect.equals(date1, headers.expires); |
| 99 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); | 99 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); |
| 100 | 100 |
| 101 headers.set(HttpHeaders.EXPIRES, "xxx"); | 101 headers.set(HttpHeaders.EXPIRES, "xxx"); |
| 102 Expect.equals("xxx", headers.value(HttpHeaders.EXPIRES)); | 102 Expect.equals("xxx", headers.value(HttpHeaders.EXPIRES)); |
| 103 Expect.equals(null, headers.expires); | 103 Expect.equals(null, headers.expires); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void testIfModifiedSince() { | 106 void testIfModifiedSince() { |
| 107 DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0); | 107 DateTime date1 = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0); |
| 108 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; | 108 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; |
| 109 DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0); | 109 DateTime date2 = new DateTime.utc(2000, DateTime.AUGUST, 16, 12, 34, 56, 0); |
| 110 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; | 110 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; |
| 111 | 111 |
| 112 _HttpHeaders headers = new _HttpHeaders("1.1"); | 112 _HttpHeaders headers = new _HttpHeaders("1.1"); |
| 113 Expect.isNull(headers.ifModifiedSince); | 113 Expect.isNull(headers.ifModifiedSince); |
| 114 headers.ifModifiedSince = date1; | 114 headers.ifModifiedSince = date1; |
| 115 Expect.equals(date1, headers.ifModifiedSince); | 115 Expect.equals(date1, headers.ifModifiedSince); |
| 116 Expect.equals(httpDate1, headers.value(HttpHeaders.IF_MODIFIED_SINCE)); | 116 Expect.equals(httpDate1, headers.value(HttpHeaders.IF_MODIFIED_SINCE)); |
| 117 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); | 117 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); |
| 118 headers.add(HttpHeaders.IF_MODIFIED_SINCE, httpDate2); | 118 headers.add(HttpHeaders.IF_MODIFIED_SINCE, httpDate2); |
| 119 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); | 119 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 void checkCookie(cookie, s) { | 324 void checkCookie(cookie, s) { |
| 325 Expect.equals(s, cookie.toString()); | 325 Expect.equals(s, cookie.toString()); |
| 326 var c = new _Cookie.fromSetCookieValue(s); | 326 var c = new _Cookie.fromSetCookieValue(s); |
| 327 checkCookiesEquals(cookie, c); | 327 checkCookiesEquals(cookie, c); |
| 328 } | 328 } |
| 329 | 329 |
| 330 Cookie cookie; | 330 Cookie cookie; |
| 331 cookie = new Cookie("name", "value"); | 331 cookie = new Cookie("name", "value"); |
| 332 Expect.equals("name=value", cookie.toString()); | 332 Expect.equals("name=value", cookie.toString()); |
| 333 DateTime date = new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0); | 333 DateTime date = new DateTime.utc(2014, DateTime.JANUARY, 5, 23, 59, 59, 0); |
| 334 cookie.expires = date; | 334 cookie.expires = date; |
| 335 checkCookie(cookie, "name=value" | 335 checkCookie(cookie, "name=value" |
| 336 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"); | 336 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"); |
| 337 cookie.maxAge = 567; | 337 cookie.maxAge = 567; |
| 338 checkCookie(cookie, "name=value" | 338 checkCookie(cookie, "name=value" |
| 339 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" | 339 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" |
| 340 "; Max-Age=567"); | 340 "; Max-Age=567"); |
| 341 cookie.domain = "example.com"; | 341 cookie.domain = "example.com"; |
| 342 checkCookie(cookie, "name=value" | 342 checkCookie(cookie, "name=value" |
| 343 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" | 343 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 testIfModifiedSince(); | 415 testIfModifiedSince(); |
| 416 testHost(); | 416 testHost(); |
| 417 testEnumeration(); | 417 testEnumeration(); |
| 418 testHeaderValue(); | 418 testHeaderValue(); |
| 419 testContentType(); | 419 testContentType(); |
| 420 testContentTypeCache(); | 420 testContentTypeCache(); |
| 421 testCookie(); | 421 testCookie(); |
| 422 testInvalidCookie(); | 422 testInvalidCookie(); |
| 423 testHeaderLists(); | 423 testHeaderLists(); |
| 424 } | 424 } |
| OLD | NEW |