Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: tests/standalone/src/io/HttpHeadersTest.dart

Issue 10191013: Add handling of the HTTP Date header (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/bin/http_impl.dart ('K') | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #source("../../../../runtime/bin/input_stream.dart"); 5 #source("../../../../runtime/bin/input_stream.dart");
6 #source("../../../../runtime/bin/output_stream.dart"); 6 #source("../../../../runtime/bin/output_stream.dart");
7 #source("../../../../runtime/bin/chunked_stream.dart"); 7 #source("../../../../runtime/bin/chunked_stream.dart");
8 #source("../../../../runtime/bin/string_stream.dart"); 8 #source("../../../../runtime/bin/string_stream.dart");
9 #source("../../../../runtime/bin/stream_util.dart"); 9 #source("../../../../runtime/bin/stream_util.dart");
10 #source("../../../../runtime/bin/http.dart"); 10 #source("../../../../runtime/bin/http.dart");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 headers.set(HttpHeaders.PRAGMA, "pragma5"); 42 headers.set(HttpHeaders.PRAGMA, "pragma5");
43 Expect.equals(1, headers[HttpHeaders.PRAGMA].length); 43 Expect.equals(1, headers[HttpHeaders.PRAGMA].length);
44 44
45 headers.set(HttpHeaders.PRAGMA, ["pragma6", "pragma7"]); 45 headers.set(HttpHeaders.PRAGMA, ["pragma6", "pragma7"]);
46 Expect.equals(2, headers[HttpHeaders.PRAGMA].length); 46 Expect.equals(2, headers[HttpHeaders.PRAGMA].length);
47 47
48 headers.removeAll(HttpHeaders.PRAGMA); 48 headers.removeAll(HttpHeaders.PRAGMA);
49 Expect.isNull(headers[HttpHeaders.PRAGMA]); 49 Expect.isNull(headers[HttpHeaders.PRAGMA]);
50 } 50 }
51 51
52 void testDate() {
53 Date date1 = new Date.withTimeZone(
54 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc());
55 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT";
56 Date date2 = new Date.withTimeZone(
57 2000, Date.AUG, 16, 12, 34, 56, 0, new TimeZone.utc());
58 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT";
59
60 _HttpHeaders headers = new _HttpHeaders();
61 Expect.isNull(headers.date);
62 headers.date = date1;
63 Expect.equals(date1, headers.date);
64 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE));
65 Expect.equals(1, headers[HttpHeaders.DATE].length);
66 headers.add(HttpHeaders.DATE, httpDate2);
67 Expect.equals(1, headers[HttpHeaders.DATE].length);
68 Expect.equals(date2, headers.date);
69 Expect.equals(httpDate2, headers.value(HttpHeaders.DATE));
70 headers.set(HttpHeaders.DATE, httpDate1);
71 Expect.equals(1, headers[HttpHeaders.DATE].length);
72 Expect.equals(date1, headers.date);
73 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE));
74
75 headers.set(HttpHeaders.DATE, "xxx");
76 Expect.equals("xxx", headers.value(HttpHeaders.DATE));
77 Expect.equals(null, headers.date);
78 }
79
52 void testExpires() { 80 void testExpires() {
53 Date date1 = new Date.withTimeZone( 81 Date date1 = new Date.withTimeZone(
54 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc()); 82 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc());
55 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; 83 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT";
56 Date date2 = new Date.withTimeZone( 84 Date date2 = new Date.withTimeZone(
57 2000, Date.AUG, 16, 12, 34, 56, 0, new TimeZone.utc()); 85 2000, Date.AUG, 16, 12, 34, 56, 0, new TimeZone.utc());
58 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; 86 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT";
59 87
60 _HttpHeaders headers = new _HttpHeaders(); 88 _HttpHeaders headers = new _HttpHeaders();
61 Expect.isNull(headers.expires); 89 Expect.isNull(headers.expires);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 Expect.equals(":1234", headers.value(HttpHeaders.HOST)); 137 Expect.equals(":1234", headers.value(HttpHeaders.HOST));
110 Expect.isNull(headers.host); 138 Expect.isNull(headers.host);
111 Expect.equals(1234, headers.port); 139 Expect.equals(1234, headers.port);
112 } 140 }
113 141
114 main() { 142 main() {
115 testMultiValue(); 143 testMultiValue();
116 testExpires(); 144 testExpires();
117 testHost(); 145 testHost();
118 } 146 }
OLDNEW
« runtime/bin/http_impl.dart ('K') | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698