| 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"); | 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 headers.set(HttpHeaders.EXPIRES, httpDate1); | 94 headers.set(HttpHeaders.EXPIRES, httpDate1); |
| 95 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); | 95 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); |
| 96 Expect.equals(date1, headers.expires); | 96 Expect.equals(date1, headers.expires); |
| 97 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); | 97 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); |
| 98 | 98 |
| 99 headers.set(HttpHeaders.EXPIRES, "xxx"); | 99 headers.set(HttpHeaders.EXPIRES, "xxx"); |
| 100 Expect.equals("xxx", headers.value(HttpHeaders.EXPIRES)); | 100 Expect.equals("xxx", headers.value(HttpHeaders.EXPIRES)); |
| 101 Expect.equals(null, headers.expires); | 101 Expect.equals(null, headers.expires); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void testIfModifiedSince() { |
| 105 Date date1 = new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true); |
| 106 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; |
| 107 Date date2 = new Date(2000, Date.AUG, 16, 12, 34, 56, 0, isUtc: true); |
| 108 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; |
| 109 |
| 110 _HttpHeaders headers = new _HttpHeaders(); |
| 111 Expect.isNull(headers.ifModifiedSince); |
| 112 headers.ifModifiedSince = date1; |
| 113 Expect.equals(date1, headers.ifModifiedSince); |
| 114 Expect.equals(httpDate1, headers.value(HttpHeaders.IF_MODIFIED_SINCE)); |
| 115 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); |
| 116 headers.add(HttpHeaders.IF_MODIFIED_SINCE, httpDate2); |
| 117 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); |
| 118 Expect.equals(date2, headers.ifModifiedSince); |
| 119 Expect.equals(httpDate2, headers.value(HttpHeaders.IF_MODIFIED_SINCE)); |
| 120 headers.set(HttpHeaders.IF_MODIFIED_SINCE, httpDate1); |
| 121 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); |
| 122 Expect.equals(date1, headers.ifModifiedSince); |
| 123 Expect.equals(httpDate1, headers.value(HttpHeaders.IF_MODIFIED_SINCE)); |
| 124 |
| 125 headers.set(HttpHeaders.IF_MODIFIED_SINCE, "xxx"); |
| 126 Expect.equals("xxx", headers.value(HttpHeaders.IF_MODIFIED_SINCE)); |
| 127 Expect.equals(null, headers.ifModifiedSince); |
| 128 } |
| 129 |
| 104 void testHost() { | 130 void testHost() { |
| 105 String host = "www.google.com"; | 131 String host = "www.google.com"; |
| 106 _HttpHeaders headers = new _HttpHeaders(); | 132 _HttpHeaders headers = new _HttpHeaders(); |
| 107 Expect.isNull(headers.host); | 133 Expect.isNull(headers.host); |
| 108 Expect.isNull(headers.port); | 134 Expect.isNull(headers.port); |
| 109 headers.host = host; | 135 headers.host = host; |
| 110 Expect.equals(host, headers.value(HttpHeaders.HOST)); | 136 Expect.equals(host, headers.value(HttpHeaders.HOST)); |
| 111 headers.port = 1234; | 137 headers.port = 1234; |
| 112 Expect.equals("$host:1234", headers.value(HttpHeaders.HOST)); | 138 Expect.equals("$host:1234", headers.value(HttpHeaders.HOST)); |
| 113 headers.port = HttpClient.DEFAULT_HTTP_PORT; | 139 headers.port = HttpClient.DEFAULT_HTTP_PORT; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 void testInvalidCookie() { | 381 void testInvalidCookie() { |
| 356 Expect.throws(() => new _Cookie.fromSetCookieValue("")); | 382 Expect.throws(() => new _Cookie.fromSetCookieValue("")); |
| 357 Expect.throws(() => new _Cookie.fromSetCookieValue("=")); | 383 Expect.throws(() => new _Cookie.fromSetCookieValue("=")); |
| 358 Expect.throws(() => new _Cookie.fromSetCookieValue("=xxx")); | 384 Expect.throws(() => new _Cookie.fromSetCookieValue("=xxx")); |
| 359 Expect.throws(() => new _Cookie.fromSetCookieValue("xxx")); | 385 Expect.throws(() => new _Cookie.fromSetCookieValue("xxx")); |
| 360 Expect.throws(() => new _Cookie.fromSetCookieValue("xxx=yyy; expires=12 jan 20
13")); | 386 Expect.throws(() => new _Cookie.fromSetCookieValue("xxx=yyy; expires=12 jan 20
13")); |
| 361 } | 387 } |
| 362 | 388 |
| 363 main() { | 389 main() { |
| 364 testMultiValue(); | 390 testMultiValue(); |
| 391 testDate(); |
| 365 testExpires(); | 392 testExpires(); |
| 393 testIfModifiedSince(); |
| 366 testHost(); | 394 testHost(); |
| 367 testEnumeration(); | 395 testEnumeration(); |
| 368 testHeaderValue(); | 396 testHeaderValue(); |
| 369 testContentType(); | 397 testContentType(); |
| 370 testContentTypeCache(); | 398 testContentTypeCache(); |
| 371 testCookie(); | 399 testCookie(); |
| 372 testInvalidCookie(); | 400 testInvalidCookie(); |
| 373 } | 401 } |
| OLD | NEW |