OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart.io; | 5 library dart.io; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import "dart:async"; | 8 import "dart:async"; |
9 import "dart:collection"; | 9 import "dart:collection"; |
10 import "dart:convert"; | 10 import "dart:convert"; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 Expect.equals(host, headers.host); | 179 Expect.equals(host, headers.host); |
180 Expect.isNull(headers.port); | 180 Expect.isNull(headers.port); |
181 | 181 |
182 headers = new _HttpHeaders("1.1"); | 182 headers = new _HttpHeaders("1.1"); |
183 headers.add(HttpHeaders.HOST, ":1234"); | 183 headers.add(HttpHeaders.HOST, ":1234"); |
184 Expect.equals(":1234", headers.value(HttpHeaders.HOST)); | 184 Expect.equals(":1234", headers.value(HttpHeaders.HOST)); |
185 Expect.isNull(headers.host); | 185 Expect.isNull(headers.host); |
186 Expect.equals(1234, headers.port); | 186 Expect.equals(1234, headers.port); |
187 } | 187 } |
188 | 188 |
| 189 void testTransferEncoding() { |
| 190 expectChunked(headers) { |
| 191 Expect.listEquals(headers['transfer-encoding'], ['chunked']); |
| 192 Expect.isTrue(headers.chunkedTransferEncoding); |
| 193 } |
| 194 |
| 195 expectNonChunked(headers) { |
| 196 Expect.isNull(headers['transfer-encoding']); |
| 197 Expect.isFalse(headers.chunkedTransferEncoding); |
| 198 } |
| 199 |
| 200 _HttpHeaders headers; |
| 201 |
| 202 headers = new _HttpHeaders("1.1"); |
| 203 headers.chunkedTransferEncoding = true; |
| 204 expectChunked(headers); |
| 205 headers.set('transfer-encoding', ['chunked']); |
| 206 expectChunked(headers); |
| 207 |
| 208 headers = new _HttpHeaders("1.1"); |
| 209 headers.set('transfer-encoding', ['chunked']); |
| 210 expectChunked(headers); |
| 211 headers.chunkedTransferEncoding = true; |
| 212 expectChunked(headers); |
| 213 |
| 214 headers = new _HttpHeaders("1.1"); |
| 215 headers.chunkedTransferEncoding = true; |
| 216 headers.chunkedTransferEncoding = false; |
| 217 expectNonChunked(headers); |
| 218 |
| 219 headers = new _HttpHeaders("1.1"); |
| 220 headers.chunkedTransferEncoding = true; |
| 221 headers.remove('transfer-encoding', 'chunked'); |
| 222 expectNonChunked(headers); |
| 223 |
| 224 headers = new _HttpHeaders("1.1"); |
| 225 headers.set('transfer-encoding', ['chunked']); |
| 226 headers.chunkedTransferEncoding = false; |
| 227 expectNonChunked(headers); |
| 228 |
| 229 headers = new _HttpHeaders("1.1"); |
| 230 headers.set('transfer-encoding', ['chunked']); |
| 231 headers.remove('transfer-encoding', 'chunked'); |
| 232 expectNonChunked(headers); |
| 233 } |
| 234 |
189 void testEnumeration() { | 235 void testEnumeration() { |
190 _HttpHeaders headers = new _HttpHeaders("1.1"); | 236 _HttpHeaders headers = new _HttpHeaders("1.1"); |
191 Expect.isNull(headers[HttpHeaders.PRAGMA]); | 237 Expect.isNull(headers[HttpHeaders.PRAGMA]); |
192 headers.add("My-Header-1", "value 1"); | 238 headers.add("My-Header-1", "value 1"); |
193 headers.add("My-Header-2", "value 2"); | 239 headers.add("My-Header-2", "value 2"); |
194 headers.add("My-Header-1", "value 3"); | 240 headers.add("My-Header-1", "value 3"); |
195 bool myHeader1 = false; | 241 bool myHeader1 = false; |
196 bool myHeader2 = false; | 242 bool myHeader2 = false; |
197 int totalValues = 0; | 243 int totalValues = 0; |
198 headers.forEach((String name, List<String> values) { | 244 headers.forEach((String name, List<String> values) { |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 // Test we handle other types correctly. | 544 // Test we handle other types correctly. |
499 test(new StringBuffer('\x00'), remove: false); | 545 test(new StringBuffer('\x00'), remove: false); |
500 } | 546 } |
501 | 547 |
502 main() { | 548 main() { |
503 testMultiValue(); | 549 testMultiValue(); |
504 testDate(); | 550 testDate(); |
505 testExpires(); | 551 testExpires(); |
506 testIfModifiedSince(); | 552 testIfModifiedSince(); |
507 testHost(); | 553 testHost(); |
| 554 testTransferEncoding(); |
508 testEnumeration(); | 555 testEnumeration(); |
509 testHeaderValue(); | 556 testHeaderValue(); |
510 testContentType(); | 557 testContentType(); |
511 testContentTypeCache(); | 558 testContentTypeCache(); |
512 testCookie(); | 559 testCookie(); |
513 testInvalidCookie(); | 560 testInvalidCookie(); |
514 testHeaderLists(); | 561 testHeaderLists(); |
515 testInvalidFieldName(); | 562 testInvalidFieldName(); |
516 testInvalidFieldValue(); | 563 testInvalidFieldValue(); |
517 } | 564 } |
OLD | NEW |