Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: tests/standalone/io/http_connection_close_test.dart

Issue 14640008: Change the signature for all network bind calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments by whesse@ Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:async"; 7 import "dart:async";
8 import "dart:io"; 8 import "dart:io";
9 import "dart:uri"; 9 import "dart:uri";
10 10
11 void testHttp10Close(bool closeRequest) { 11 void testHttp10Close(bool closeRequest) {
12 HttpServer.bind().then((server) { 12 HttpServer.bind("127.0.0.1", 0).then((server) {
13 server.listen((request) { 13 server.listen((request) {
14 request.response.close(); 14 request.response.close();
15 }); 15 });
16 16
17 Socket.connect("127.0.0.1", server.port) 17 Socket.connect("127.0.0.1", server.port)
18 .then((socket) { 18 .then((socket) {
19 socket.write("GET / HTTP/1.0\r\n\r\n"); 19 socket.write("GET / HTTP/1.0\r\n\r\n");
20 socket.listen( 20 socket.listen(
21 (data) {}, 21 (data) {},
22 onDone: () { 22 onDone: () {
23 if (!closeRequest) socket.destroy(); 23 if (!closeRequest) socket.destroy();
24 server.close(); 24 server.close();
25 }); 25 });
26 if (closeRequest) socket.close(); 26 if (closeRequest) socket.close();
27 }); 27 });
28 }); 28 });
29 } 29 }
30 30
31 void testHttp11Close(bool closeRequest) { 31 void testHttp11Close(bool closeRequest) {
32 HttpServer.bind().then((server) { 32 HttpServer.bind("127.0.0.1", 0).then((server) {
33 server.listen((request) { 33 server.listen((request) {
34 request.response.close(); 34 request.response.close();
35 }); 35 });
36 36
37 Socket.connect("127.0.0.1", server.port) 37 Socket.connect("127.0.0.1", server.port)
38 .then((socket) { 38 .then((socket) {
39 List<int> buffer = new List<int>(1024); 39 List<int> buffer = new List<int>(1024);
40 socket.write("GET / HTTP/1.1\r\nConnection: close\r\n\r\n"); 40 socket.write("GET / HTTP/1.1\r\nConnection: close\r\n\r\n");
41 socket.listen( 41 socket.listen(
42 (data) {}, 42 (data) {},
43 onDone: () { 43 onDone: () {
44 if (!closeRequest) socket.destroy(); 44 if (!closeRequest) socket.destroy();
45 server.close(); 45 server.close();
46 }); 46 });
47 if (closeRequest) socket.close(); 47 if (closeRequest) socket.close();
48 }); 48 });
49 }); 49 });
50 } 50 }
51 51
52 void testStreamResponse() { 52 void testStreamResponse() {
53 HttpServer.bind().then((server) { 53 HttpServer.bind("127.0.0.1", 0).then((server) {
54 server.listen((request) { 54 server.listen((request) {
55 var timer = new Timer.periodic(const Duration(milliseconds: 0), (_) { 55 var timer = new Timer.periodic(const Duration(milliseconds: 0), (_) {
56 request.response.write( 56 request.response.write(
57 'data:${new DateTime.now().millisecondsSinceEpoch}\n\n'); 57 'data:${new DateTime.now().millisecondsSinceEpoch}\n\n');
58 }); 58 });
59 request.response.done 59 request.response.done
60 .whenComplete(() { 60 .whenComplete(() {
61 timer.cancel(); 61 timer.cancel();
62 }) 62 })
63 .catchError((_) {}); 63 .catchError((_) {});
(...skipping 18 matching lines...) Expand all
82 }); 82 });
83 } 83 }
84 84
85 main() { 85 main() {
86 testHttp10Close(false); 86 testHttp10Close(false);
87 testHttp10Close(true); 87 testHttp10Close(true);
88 testHttp11Close(false); 88 testHttp11Close(false);
89 testHttp11Close(true); 89 testHttp11Close(true);
90 testStreamResponse(); 90 testStreamResponse();
91 } 91 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_compression_test.dart ('k') | tests/standalone/io/http_connection_header_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698