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(1999, month: Date.JUN, day: 11, hour: 18, minute: 46, |
| 56 second: 53, millisecond: 0, isUtc: true); |
56 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; | 57 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); | 58 Date date2 = new Date(2000, month: Date.AUG, day: 16, hour: 12, minute: 34, |
| 59 second: 56, millisecond: 0, isUtc: true); |
58 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; | 60 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; |
59 | 61 |
60 _HttpHeaders headers = new _HttpHeaders(); | 62 _HttpHeaders headers = new _HttpHeaders(); |
61 Expect.isNull(headers.date); | 63 Expect.isNull(headers.date); |
62 headers.date = date1; | 64 headers.date = date1; |
63 Expect.equals(date1, headers.date); | 65 Expect.equals(date1, headers.date); |
64 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); | 66 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); |
65 Expect.equals(1, headers[HttpHeaders.DATE].length); | 67 Expect.equals(1, headers[HttpHeaders.DATE].length); |
66 headers.add(HttpHeaders.DATE, httpDate2); | 68 headers.add(HttpHeaders.DATE, httpDate2); |
67 Expect.equals(1, headers[HttpHeaders.DATE].length); | 69 Expect.equals(1, headers[HttpHeaders.DATE].length); |
68 Expect.equals(date2, headers.date); | 70 Expect.equals(date2, headers.date); |
69 Expect.equals(httpDate2, headers.value(HttpHeaders.DATE)); | 71 Expect.equals(httpDate2, headers.value(HttpHeaders.DATE)); |
70 headers.set(HttpHeaders.DATE, httpDate1); | 72 headers.set(HttpHeaders.DATE, httpDate1); |
71 Expect.equals(1, headers[HttpHeaders.DATE].length); | 73 Expect.equals(1, headers[HttpHeaders.DATE].length); |
72 Expect.equals(date1, headers.date); | 74 Expect.equals(date1, headers.date); |
73 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); | 75 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); |
74 | 76 |
75 headers.set(HttpHeaders.DATE, "xxx"); | 77 headers.set(HttpHeaders.DATE, "xxx"); |
76 Expect.equals("xxx", headers.value(HttpHeaders.DATE)); | 78 Expect.equals("xxx", headers.value(HttpHeaders.DATE)); |
77 Expect.equals(null, headers.date); | 79 Expect.equals(null, headers.date); |
78 } | 80 } |
79 | 81 |
80 void testExpires() { | 82 void testExpires() { |
81 Date date1 = new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true); | 83 Date date1 = new Date(1999, month: Date.JUN, day: 11, hour: 18, minute: 46, |
| 84 second: 53, millisecond: 0, isUtc: true); |
82 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; | 85 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); | 86 Date date2 = new Date(2000, month: Date.AUG, day: 16, hour: 12, minute: 34, |
| 87 second: 56, millisecond: 0, isUtc: true); |
84 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; | 88 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; |
85 | 89 |
86 _HttpHeaders headers = new _HttpHeaders(); | 90 _HttpHeaders headers = new _HttpHeaders(); |
87 Expect.isNull(headers.expires); | 91 Expect.isNull(headers.expires); |
88 headers.expires = date1; | 92 headers.expires = date1; |
89 Expect.equals(date1, headers.expires); | 93 Expect.equals(date1, headers.expires); |
90 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); | 94 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); |
91 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); | 95 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); |
92 headers.add(HttpHeaders.EXPIRES, httpDate2); | 96 headers.add(HttpHeaders.EXPIRES, httpDate2); |
93 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); | 97 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); |
94 Expect.equals(date2, headers.expires); | 98 Expect.equals(date2, headers.expires); |
95 Expect.equals(httpDate2, headers.value(HttpHeaders.EXPIRES)); | 99 Expect.equals(httpDate2, headers.value(HttpHeaders.EXPIRES)); |
96 headers.set(HttpHeaders.EXPIRES, httpDate1); | 100 headers.set(HttpHeaders.EXPIRES, httpDate1); |
97 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); | 101 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); |
98 Expect.equals(date1, headers.expires); | 102 Expect.equals(date1, headers.expires); |
99 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); | 103 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); |
100 | 104 |
101 headers.set(HttpHeaders.EXPIRES, "xxx"); | 105 headers.set(HttpHeaders.EXPIRES, "xxx"); |
102 Expect.equals("xxx", headers.value(HttpHeaders.EXPIRES)); | 106 Expect.equals("xxx", headers.value(HttpHeaders.EXPIRES)); |
103 Expect.equals(null, headers.expires); | 107 Expect.equals(null, headers.expires); |
104 } | 108 } |
105 | 109 |
106 void testIfModifiedSince() { | 110 void testIfModifiedSince() { |
107 Date date1 = new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true); | 111 Date date1 = new Date(1999, month: Date.JUN, day: 11, day: 18, minute: 46, |
| 112 second: 53, millisecond: 0, isUtc: true); |
108 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; | 113 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); | 114 Date date2 = new Date(2000, month: Date.AUG, day: 16, day: 12, minute: 34, |
| 115 second: 56, millisecond: 0, isUtc: true); |
110 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; | 116 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; |
111 | 117 |
112 _HttpHeaders headers = new _HttpHeaders(); | 118 _HttpHeaders headers = new _HttpHeaders(); |
113 Expect.isNull(headers.ifModifiedSince); | 119 Expect.isNull(headers.ifModifiedSince); |
114 headers.ifModifiedSince = date1; | 120 headers.ifModifiedSince = date1; |
115 Expect.equals(date1, headers.ifModifiedSince); | 121 Expect.equals(date1, headers.ifModifiedSince); |
116 Expect.equals(httpDate1, headers.value(HttpHeaders.IF_MODIFIED_SINCE)); | 122 Expect.equals(httpDate1, headers.value(HttpHeaders.IF_MODIFIED_SINCE)); |
117 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); | 123 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); |
118 headers.add(HttpHeaders.IF_MODIFIED_SINCE, httpDate2); | 124 headers.add(HttpHeaders.IF_MODIFIED_SINCE, httpDate2); |
119 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); | 125 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 testIfModifiedSince(); | 408 testIfModifiedSince(); |
403 testHost(); | 409 testHost(); |
404 testEnumeration(); | 410 testEnumeration(); |
405 testHeaderValue(); | 411 testHeaderValue(); |
406 testContentType(); | 412 testContentType(); |
407 testContentTypeCache(); | 413 testContentTypeCache(); |
408 testCookie(); | 414 testCookie(); |
409 testInvalidCookie(); | 415 testInvalidCookie(); |
410 testHeaderLists(); | 416 testHeaderLists(); |
411 } | 417 } |
OLD | NEW |