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 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import "dart:isolate"; | 7 import "dart:isolate"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 void setConnectionHeaders(HttpHeaders headers) { | 10 void setConnectionHeaders(HttpHeaders headers) { |
(...skipping 14 matching lines...) Expand all Loading... |
25 if (persistentConnection) { | 25 if (persistentConnection) { |
26 Expect.equals(2, headers[HttpHeaders.CONNECTION].length); | 26 Expect.equals(2, headers[HttpHeaders.CONNECTION].length); |
27 } else { | 27 } else { |
28 Expect.equals(3, headers[HttpHeaders.CONNECTION].length); | 28 Expect.equals(3, headers[HttpHeaders.CONNECTION].length); |
29 Expect.isTrue(headers[HttpHeaders.CONNECTION].any( | 29 Expect.isTrue(headers[HttpHeaders.CONNECTION].any( |
30 (value) => value.toLowerCase() == "close")); | 30 (value) => value.toLowerCase() == "close")); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 void test(int totalConnections, bool clientPersistentConnection) { | 34 void test(int totalConnections, bool clientPersistentConnection) { |
35 HttpServer.bind().then((server) { | 35 HttpServer.bind("127.0.0.1", 0).then((server) { |
36 server.listen((HttpRequest request) { | 36 server.listen((HttpRequest request) { |
37 // Check expected request. | 37 // Check expected request. |
38 Expect.equals(clientPersistentConnection, request.persistentConnection); | 38 Expect.equals(clientPersistentConnection, request.persistentConnection); |
39 Expect.equals(clientPersistentConnection, | 39 Expect.equals(clientPersistentConnection, |
40 request.response.persistentConnection); | 40 request.response.persistentConnection); |
41 checkExpectedConnectionHeaders(request.headers, | 41 checkExpectedConnectionHeaders(request.headers, |
42 request.persistentConnection); | 42 request.persistentConnection); |
43 | 43 |
44 // Generate response. If the client signaled non-persistent | 44 // Generate response. If the client signaled non-persistent |
45 // connection the server should not need to set it. | 45 // connection the server should not need to set it. |
(...skipping 27 matching lines...) Expand all Loading... |
73 }); | 73 }); |
74 } | 74 } |
75 }); | 75 }); |
76 } | 76 } |
77 | 77 |
78 | 78 |
79 void main() { | 79 void main() { |
80 test(2, false); | 80 test(2, false); |
81 test(2, true); | 81 test(2, true); |
82 } | 82 } |
OLD | NEW |