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

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

Issue 262433003: Add writeHeaders argument to HttpResponse::detachSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix comment. Created 6 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
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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 "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 30 matching lines...) Expand all
41 "content-length: 0\r\n" 41 "content-length: 0\r\n"
42 "\r\n" 42 "\r\n"
43 "Test!", 43 "Test!",
44 body.toString()); 44 body.toString());
45 socket.close(); 45 socket.close();
46 }); 46 });
47 }); 47 });
48 }); 48 });
49 } 49 }
50 50
51 void testServerDetachSocketNoWriteHeaders() {
52 HttpServer.bind("127.0.0.1", 0).then((server) {
53 server.listen((request) {
54 var response = request.response;
55 response.contentLength = 0;
56 response.detachSocket(writeHeaders: false).then((socket) {
57 Expect.isNotNull(socket);
58 var body = new StringBuffer();
59 socket.listen(
60 (data) => body.write(new String.fromCharCodes(data)),
61 onDone: () => Expect.equals("Some data", body.toString()));
62 socket.write("Test!");
63 socket.close();
64 });
65 server.close();
66 });
67
68 Socket.connect("127.0.0.1", server.port).then((socket) {
69 socket.write("GET / HTTP/1.1\r\n"
70 "content-length: 0\r\n\r\n"
71 "Some data");
72 var body = new StringBuffer();
73 socket.listen(
74 (data) => body.write(new String.fromCharCodes(data)),
75 onDone: () {
76 Expect.equals("Test!",body.toString());
77 socket.close();
78 });
79 });
80 });
81 }
82
51 void testBadServerDetachSocket() { 83 void testBadServerDetachSocket() {
52 HttpServer.bind("127.0.0.1", 0).then((server) { 84 HttpServer.bind("127.0.0.1", 0).then((server) {
53 server.listen((request) { 85 server.listen((request) {
54 var response = request.response; 86 var response = request.response;
55 response.contentLength = 0; 87 response.contentLength = 0;
56 response.close(); 88 response.close();
57 Expect.throws(response.detachSocket); 89 Expect.throws(response.detachSocket);
58 server.close(); 90 server.close();
59 }); 91 });
60 92
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 }); 140 });
109 socket.write("Some data"); 141 socket.write("Some data");
110 socket.close(); 142 socket.close();
111 }); 143 });
112 }); 144 });
113 }); 145 });
114 } 146 }
115 147
116 void main() { 148 void main() {
117 testServerDetachSocket(); 149 testServerDetachSocket();
150 testServerDetachSocketNoWriteHeaders();
118 testBadServerDetachSocket(); 151 testBadServerDetachSocket();
119 testClientDetachSocket(); 152 testClientDetachSocket();
120 } 153 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698