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 "dart:async"; | 6 import "dart:async"; |
7 import "dart:io"; | 7 import "dart:io"; |
8 import "dart:uri"; | 8 import "dart:uri"; |
9 | 9 |
10 void testHttp10Close(bool closeRequest) { | 10 void testHttp10Close(bool closeRequest) { |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 void testHttp11Close(bool closeRequest) { | 30 void testHttp11Close(bool closeRequest) { |
31 HttpServer.bind().then((server) { | 31 HttpServer.bind().then((server) { |
32 server.listen((request) { | 32 server.listen((request) { |
33 request.response.close(); | 33 request.response.close(); |
34 }); | 34 }); |
35 | 35 |
36 Socket.connect("127.0.0.1", server.port) | 36 Socket.connect("127.0.0.1", server.port) |
37 .then((socket) { | 37 .then((socket) { |
38 List<int> buffer = new List<int>.fixedLength(1024); | 38 List<int> buffer = new List<int>(1024); |
39 socket.addString("GET / HTTP/1.1\r\nConnection: close\r\n\r\n"); | 39 socket.addString("GET / HTTP/1.1\r\nConnection: close\r\n\r\n"); |
40 socket.listen( | 40 socket.listen( |
41 (data) {}, | 41 (data) {}, |
42 onDone: () { | 42 onDone: () { |
43 if (!closeRequest) socket.destroy(); | 43 if (!closeRequest) socket.destroy(); |
44 server.close(); | 44 server.close(); |
45 }); | 45 }); |
46 if (closeRequest) socket.close(); | 46 if (closeRequest) socket.close(); |
47 }); | 47 }); |
48 }); | 48 }); |
(...skipping 28 matching lines...) Expand all Loading... |
77 }); | 77 }); |
78 } | 78 } |
79 | 79 |
80 main() { | 80 main() { |
81 testHttp10Close(false); | 81 testHttp10Close(false); |
82 testHttp10Close(true); | 82 testHttp10Close(true); |
83 testHttp11Close(false); | 83 testHttp11Close(false); |
84 testHttp11Close(true); | 84 testHttp11Close(true); |
85 testStreamResponse(); | 85 testStreamResponse(); |
86 } | 86 } |
OLD | NEW |