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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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:isolate"; 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) {
11 HttpServer server = new HttpServer(); 11 HttpServer server = new HttpServer();
12 server.listen("127.0.0.1", 0, backlog: 5); 12 server.listen("127.0.0.1", 0, backlog: 5);
13 13
14 Socket socket = new Socket("127.0.0.1", server.port); 14 Socket socket = new Socket("127.0.0.1", server.port);
15 socket.onConnect = () { 15 socket.onConnect = () {
16 List<int> buffer = new List<int>(1024); 16 List<int> buffer = new List<int>.fixedLength(1024);
17 socket.outputStream.writeString("GET / HTTP/1.0\r\n\r\n"); 17 socket.outputStream.writeString("GET / HTTP/1.0\r\n\r\n");
18 if (closeRequest) socket.outputStream.close(); 18 if (closeRequest) socket.outputStream.close();
19 socket.onData = () => socket.readList(buffer, 0, buffer.length); 19 socket.onData = () => socket.readList(buffer, 0, buffer.length);
20 socket.onClosed = () { 20 socket.onClosed = () {
21 if (!closeRequest) socket.close(true); 21 if (!closeRequest) socket.close(true);
22 server.close(); 22 server.close();
23 }; 23 };
24 }; 24 };
25 } 25 }
26 26
27 void testHttp11Close(bool closeRequest) { 27 void testHttp11Close(bool closeRequest) {
28 HttpServer server = new HttpServer(); 28 HttpServer server = new HttpServer();
29 server.listen("127.0.0.1", 0, backlog: 5); 29 server.listen("127.0.0.1", 0, backlog: 5);
30 30
31 Socket socket = new Socket("127.0.0.1", server.port); 31 Socket socket = new Socket("127.0.0.1", server.port);
32 socket.onConnect = () { 32 socket.onConnect = () {
33 List<int> buffer = new List<int>(1024); 33 List<int> buffer = new List<int>.fixedLength(1024);
34 socket.outputStream.writeString( 34 socket.outputStream.writeString(
35 "GET / HTTP/1.1\r\nConnection: close\r\n\r\n"); 35 "GET / HTTP/1.1\r\nConnection: close\r\n\r\n");
36 if (closeRequest) socket.outputStream.close(); 36 if (closeRequest) socket.outputStream.close();
37 socket.onData = () => socket.readList(buffer, 0, buffer.length); 37 socket.onData = () => socket.readList(buffer, 0, buffer.length);
38 socket.onClosed = () { 38 socket.onClosed = () {
39 if (!closeRequest) socket.close(true); 39 if (!closeRequest) socket.close(true);
40 server.close(); 40 server.close();
41 }; 41 };
42 }; 42 };
43 } 43 }
(...skipping 29 matching lines...) Expand all
73 connection.onError = (e) => Expect.isTrue(e is HttpException); 73 connection.onError = (e) => Expect.isTrue(e is HttpException);
74 } 74 }
75 75
76 main() { 76 main() {
77 testHttp10Close(false); 77 testHttp10Close(false);
78 testHttp10Close(true); 78 testHttp10Close(true);
79 testHttp11Close(false); 79 testHttp11Close(false);
80 testHttp11Close(true); 80 testHttp11Close(true);
81 testStreamResponse(); 81 testStreamResponse();
82 } 82 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_auth_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