| 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 #source("../../../runtime/bin/input_stream.dart"); |
| 6 #source("../../../runtime/bin/output_stream.dart"); |
| 7 #source("../../../runtime/bin/chunked_stream.dart"); |
| 8 #source("../../../runtime/bin/string_stream.dart"); |
| 9 #source("../../../runtime/bin/stream_util.dart"); |
| 10 #source("../../../runtime/bin/http.dart"); |
| 11 #source("../../../runtime/bin/http_impl.dart"); |
| 12 #source("../../../runtime/bin/http_parser.dart"); |
| 5 #source("../../../runtime/bin/http_utils.dart"); | 13 #source("../../../runtime/bin/http_utils.dart"); |
| 6 | 14 |
| 7 class HttpException implements Exception { | |
| 8 const HttpException([String this.message = ""]); | |
| 9 String toString() => "HttpException: $message"; | |
| 10 final String message; | |
| 11 } | |
| 12 | |
| 13 void testParseHttpDate() { | 15 void testParseHttpDate() { |
| 14 TimeZone utc = new TimeZone.utc(); | 16 TimeZone utc = new TimeZone.utc(); |
| 15 Date date; | 17 Date date; |
| 16 date = new Date.withTimeZone(1999, Date.JUN, 11, 18, 46, 53, 0, utc); | 18 date = new Date.withTimeZone(1999, Date.JUN, 11, 18, 46, 53, 0, utc); |
| 17 Expect.equals(date, _HttpUtils.parseDate("Fri, 11 Jun 1999 18:46:53 GMT")); | 19 Expect.equals(date, _HttpUtils.parseDate("Fri, 11 Jun 1999 18:46:53 GMT")); |
| 18 Expect.equals(date, _HttpUtils.parseDate("Friday, 11-Jun-1999 18:46:53 GMT")); | 20 Expect.equals(date, _HttpUtils.parseDate("Friday, 11-Jun-1999 18:46:53 GMT")); |
| 19 Expect.equals(date, _HttpUtils.parseDate("Fri Jun 11 18:46:53 1999")); | 21 Expect.equals(date, _HttpUtils.parseDate("Fri Jun 11 18:46:53 1999")); |
| 20 | 22 |
| 21 date = new Date.withTimeZone(1970, Date.JAN, 1, 0, 0, 0, 0, utc); | 23 date = new Date.withTimeZone(1970, Date.JAN, 1, 0, 0, 0, 0, utc); |
| 22 Expect.equals(date, _HttpUtils.parseDate("Thu, 1 Jan 1970 00:00:00 GMT")); | 24 Expect.equals(date, _HttpUtils.parseDate("Thu, 1 Jan 1970 00:00:00 GMT")); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 Expect.throws(() { | 84 Expect.throws(() { |
| 83 _HttpUtils.parseDate("$valid "); | 85 _HttpUtils.parseDate("$valid "); |
| 84 }); | 86 }); |
| 85 } | 87 } |
| 86 | 88 |
| 87 void main() { | 89 void main() { |
| 88 testParseHttpDate(); | 90 testParseHttpDate(); |
| 89 testFormatParseHttpDate(); | 91 testFormatParseHttpDate(); |
| 90 testParseHttpDateFailures(); | 92 testParseHttpDateFailures(); |
| 91 } | 93 } |
| OLD | NEW |