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

Side by Side Diff: tests/standalone/io/http_10_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
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | tests/standalone/io/http_client_request_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // (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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "dart:isolate"; 10 import "dart:isolate";
(...skipping 27 matching lines...) Expand all
38 Socket.connect("127.0.0.1", server.port).then((socket) { 38 Socket.connect("127.0.0.1", server.port).then((socket) {
39 socket.write("GET / HTTP/1.0\r\n\r\n"); 39 socket.write("GET / HTTP/1.0\r\n\r\n");
40 40
41 List<int> response = []; 41 List<int> response = [];
42 socket.listen( 42 socket.listen(
43 response.addAll, 43 response.addAll,
44 onDone: () { 44 onDone: () {
45 count++; 45 count++;
46 socket.destroy(); 46 socket.destroy();
47 String s = new String.fromCharCodes(response).toLowerCase(); 47 String s = new String.fromCharCodes(response).toLowerCase();
48 Expect.equals("z", s[s.length - 1]);
49 Expect.isTrue(s.indexOf("\r\ncontent-length: 1\r\n") > 0); 48 Expect.isTrue(s.indexOf("\r\ncontent-length: 1\r\n") > 0);
50 Expect.equals(-1, s.indexOf("keep-alive")); 49 Expect.equals(-1, s.indexOf("keep-alive"));
51 if (count < 10) { 50 if (count < 10) {
52 makeRequest(); 51 makeRequest();
53 } else { 52 } else {
54 server.close(); 53 server.close();
55 } 54 }
56 }); 55 });
57 }); 56 });
58 } 57 }
59 makeRequest(); 58 makeRequest();
60 }); 59 });
61 } 60 }
62 61
63 62
64 // Client makes a HTTP 1.0 request and the server does not set a 63 // Client makes a HTTP 1.0 request and the server does not set a
65 // content length so it has to close the connection to mark the end of 64 // content length so it has to close the connection to mark the end of
66 // the response. 65 // the response.
67 void testHttp10ServerClose() { 66 void testHttp10ServerClose() {
68 HttpServer.bind().then((server) { 67 HttpServer.bind().then((server) {
69 server.listen( 68 server.listen(
70 (HttpRequest request) { 69 (HttpRequest request) {
71 Expect.isNull(request.headers.value('content-length')); 70 Expect.isNull(request.headers.value('content-length'));
72 Expect.equals(-1, request.contentLength); 71 Expect.equals(-1, request.contentLength);
73 var response = request.response; 72 request.listen((_) {}, onDone: () {
74 Expect.equals("1.0", request.protocolVersion); 73 var response = request.response;
75 response.write("Z"); 74 Expect.equals("1.0", request.protocolVersion);
76 response.close(); 75 response.write("Z");
76 response.close();
77 });
77 }, 78 },
78 onError: (e) => Expect.fail("Unexpected error $e")); 79 onError: (e) => Expect.fail("Unexpected error $e"));
79 80
80 int count = 0; 81 int count = 0;
81 makeRequest() { 82 makeRequest() {
82 Socket.connect("127.0.0.1", server.port).then((socket) { 83 Socket.connect("127.0.0.1", server.port).then((socket) {
83 socket.write("GET / HTTP/1.0\r\n\r\n"); 84 socket.write("GET / HTTP/1.0\r\n");
84 socket.write("Connection: Keep-Alive\r\n\r\n"); 85 socket.write("Connection: Keep-Alive\r\n\r\n");
85 86
86 List<int> response = []; 87 List<int> response = [];
87 socket.listen( 88 socket.listen(
88 response.addAll, 89 response.addAll,
89 onDone: () { 90 onDone: () {
90 socket.destroy(); 91 socket.destroy();
91 count++; 92 count++;
92 String s = new String.fromCharCodes(response).toLowerCase(); 93 String s = new String.fromCharCodes(response).toLowerCase();
93 print(s);
94 Expect.equals("z", s[s.length - 1]); 94 Expect.equals("z", s[s.length - 1]);
95 Expect.equals(-1, s.indexOf("content-length:")); 95 Expect.equals(-1, s.indexOf("content-length:"));
96 Expect.equals(-1, s.indexOf("keep-alive")); 96 Expect.equals(-1, s.indexOf("keep-alive"));
97 if (count < 10) { 97 if (count < 10) {
98 makeRequest(); 98 makeRequest();
99 } else { 99 } else {
100 server.close(); 100 server.close();
101 } 101 }
102 }, 102 },
103 onError: (e) => print(e)); 103 onError: (e) => print(e));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 }); 199 });
200 }); 200 });
201 } 201 }
202 makeRequest(); 202 makeRequest();
203 }); 203 });
204 } 204 }
205 205
206 206
207 void main() { 207 void main() {
208 testHttp10NoKeepAlive(); 208 testHttp10NoKeepAlive();
209 // TODO(8871): This test fails with short socket writes. 209 testHttp10ServerClose();
210 //testHttp10ServerClose();
211 testHttp10KeepAlive(); 210 testHttp10KeepAlive();
212 testHttp10KeepAliveServerCloses(); 211 testHttp10KeepAliveServerCloses();
213 } 212 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | tests/standalone/io/http_client_request_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698