OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('dart:math'); | 5 #import('dart:math'); |
6 | 6 |
7 #source("../../../runtime/bin/input_stream.dart"); | 7 #source("../../../runtime/bin/input_stream.dart"); |
8 #source("../../../runtime/bin/output_stream.dart"); | 8 #source("../../../runtime/bin/output_stream.dart"); |
9 #source("../../../runtime/bin/chunked_stream.dart"); | 9 #source("../../../runtime/bin/chunked_stream.dart"); |
10 #source("../../../runtime/bin/string_stream.dart"); | 10 #source("../../../runtime/bin/string_stream.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 Date date1 = new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true); | 55 Date date1 = new Date.utc(1999, Date.JUN, 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 Date date2 = new Date(2000, Date.AUG, 16, 12, 34, 56, 0, isUtc: true); | 57 Date date2 = new Date.utc(2000, Date.AUG, 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(); | 60 _HttpHeaders headers = new _HttpHeaders(); |
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 Date date1 = new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true); | 81 Date date1 = new Date.utc(1999, Date.JUN, 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 Date date2 = new Date(2000, Date.AUG, 16, 12, 34, 56, 0, isUtc: true); | 83 Date date2 = new Date.utc(2000, Date.AUG, 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(); | 86 _HttpHeaders headers = new _HttpHeaders(); |
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 Date date1 = new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true); | 107 Date date1 = new Date.utc(1999, Date.JUN, 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 Date date2 = new Date(2000, Date.AUG, 16, 12, 34, 56, 0, isUtc: true); | 109 Date date2 = new Date.utc(2000, Date.AUG, 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(); | 112 _HttpHeaders headers = new _HttpHeaders(); |
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 310 |
311 void checkCookie(cookie, s) { | 311 void checkCookie(cookie, s) { |
312 Expect.equals(s, cookie.toString()); | 312 Expect.equals(s, cookie.toString()); |
313 var c = new _Cookie.fromSetCookieValue(s); | 313 var c = new _Cookie.fromSetCookieValue(s); |
314 checkCookiesEquals(cookie, c); | 314 checkCookiesEquals(cookie, c); |
315 } | 315 } |
316 | 316 |
317 Cookie cookie; | 317 Cookie cookie; |
318 cookie = new Cookie("name", "value"); | 318 cookie = new Cookie("name", "value"); |
319 Expect.equals("name=value", cookie.toString()); | 319 Expect.equals("name=value", cookie.toString()); |
320 Date date = new Date(2014, Date.JAN, 5, 23, 59, 59, 0, isUtc: true); | 320 Date date = new Date.utc(2014, Date.JAN, 5, 23, 59, 59, 0); |
321 cookie.expires = date; | 321 cookie.expires = date; |
322 checkCookie(cookie, "name=value" | 322 checkCookie(cookie, "name=value" |
323 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"); | 323 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"); |
324 cookie.maxAge = 567; | 324 cookie.maxAge = 567; |
325 checkCookie(cookie, "name=value" | 325 checkCookie(cookie, "name=value" |
326 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" | 326 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" |
327 "; Max-Age=567"); | 327 "; Max-Age=567"); |
328 cookie.domain = "example.com"; | 328 cookie.domain = "example.com"; |
329 checkCookie(cookie, "name=value" | 329 checkCookie(cookie, "name=value" |
330 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" | 330 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 testIfModifiedSince(); | 402 testIfModifiedSince(); |
403 testHost(); | 403 testHost(); |
404 testEnumeration(); | 404 testEnumeration(); |
405 testHeaderValue(); | 405 testHeaderValue(); |
406 testContentType(); | 406 testContentType(); |
407 testContentTypeCache(); | 407 testContentTypeCache(); |
408 testCookie(); | 408 testCookie(); |
409 testInvalidCookie(); | 409 testInvalidCookie(); |
410 testHeaderLists(); | 410 testHeaderLists(); |
411 } | 411 } |
OLD | NEW |