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

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

Issue 12655003: Buffer the entire http header to one packet, and buffer other data in chunks of 4-16 kb. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 "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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 server.close(); 44 server.close();
45 }); 45 });
46 if (closeRequest) socket.close(); 46 if (closeRequest) socket.close();
47 }); 47 });
48 }); 48 });
49 } 49 }
50 50
51 void testStreamResponse() { 51 void testStreamResponse() {
52 HttpServer.bind().then((server) { 52 HttpServer.bind().then((server) {
53 server.listen((request) { 53 server.listen((request) {
54 // TODO(ajohnsen): Use timer (see old version). 54 var timer = new Timer.repeating(const Duration(milliseconds: 0), (_) {
55 for (int i = 0; i < 10; i++) {
56 request.response.write( 55 request.response.write(
57 'data:${new DateTime.now().millisecondsSinceEpoch}\n\n'); 56 'data:${new DateTime.now().millisecondsSinceEpoch}\n\n');
58 } 57 });
58 request.response.done
59 .whenComplete(() {
60 timer.cancel();
61 })
62 .catchError((_) {});
59 }); 63 });
60 64
61 var client = new HttpClient(); 65 var client = new HttpClient();
62 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}")) 66 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}"))
63 .then((request) => request.close()) 67 .then((request) => request.close())
64 .then((response) { 68 .then((response) {
65 int bytes = 0; 69 int bytes = 0;
66 response.listen( 70 response.listen(
67 (data) { 71 (data) {
68 bytes += data.length; 72 bytes += data.length;
69 if (bytes > 100) { 73 if (bytes > 100) {
70 client.close(force: true); 74 client.close(force: true);
71 } 75 }
72 }, 76 },
73 onError: (error) { 77 onError: (error) {
74 server.close(); 78 server.close();
75 }); 79 });
76 }); 80 });
77 }); 81 });
78 } 82 }
79 83
80 main() { 84 main() {
81 testHttp10Close(false); 85 testHttp10Close(false);
82 testHttp10Close(true); 86 testHttp10Close(true);
83 testHttp11Close(false); 87 testHttp11Close(false);
84 testHttp11Close(true); 88 testHttp11Close(true);
85 testStreamResponse(); 89 testStreamResponse();
86 } 90 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_client_request_test.dart ('k') | tests/standalone/io/http_content_length_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698