| OLD | NEW |
| 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 "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 response.contentLength = 1; | 25 response.contentLength = 1; |
| 26 Expect.equals("1.0", request.protocolVersion); | 26 Expect.equals("1.0", request.protocolVersion); |
| 27 response.done | 27 response.done |
| 28 .then((_) => Expect.fail("Unexpected response completion")) | 28 .then((_) => Expect.fail("Unexpected response completion")) |
| 29 .catchError((error) => Expect.isTrue(error is HttpException)); | 29 .catchError((error) => Expect.isTrue(error is HttpException)); |
| 30 response.write("Z"); | 30 response.write("Z"); |
| 31 response.write("Z"); | 31 response.write("Z"); |
| 32 response.close(); | 32 response.close(); |
| 33 response.write("x"); | 33 response.write("x"); |
| 34 }, | 34 }, |
| 35 onError: (e) { | 35 onError: (e, trace) { |
| 36 String msg = "Unexpected error $e"; | 36 String msg = "Unexpected error $e"; |
| 37 var trace = getAttachedStackTrace(e); | |
| 38 if (trace != null) msg += "\nStackTrace: $trace"; | 37 if (trace != null) msg += "\nStackTrace: $trace"; |
| 39 Expect.fail(msg); | 38 Expect.fail(msg); |
| 40 }); | 39 }); |
| 41 | 40 |
| 42 int count = 0; | 41 int count = 0; |
| 43 makeRequest() { | 42 makeRequest() { |
| 44 Socket.connect("127.0.0.1", server.port).then((socket) { | 43 Socket.connect("127.0.0.1", server.port).then((socket) { |
| 45 socket.write("GET / HTTP/1.0\r\n\r\n"); | 44 socket.write("GET / HTTP/1.0\r\n\r\n"); |
| 46 | 45 |
| 47 List<int> response = []; | 46 List<int> response = []; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 75 (HttpRequest request) { | 74 (HttpRequest request) { |
| 76 Expect.isNull(request.headers.value('content-length')); | 75 Expect.isNull(request.headers.value('content-length')); |
| 77 Expect.equals(-1, request.contentLength); | 76 Expect.equals(-1, request.contentLength); |
| 78 request.listen((_) {}, onDone: () { | 77 request.listen((_) {}, onDone: () { |
| 79 var response = request.response; | 78 var response = request.response; |
| 80 Expect.equals("1.0", request.protocolVersion); | 79 Expect.equals("1.0", request.protocolVersion); |
| 81 response.write("Z"); | 80 response.write("Z"); |
| 82 response.close(); | 81 response.close(); |
| 83 }); | 82 }); |
| 84 }, | 83 }, |
| 85 onError: (e) { | 84 onError: (e, trace) { |
| 86 String msg = "Unexpected error $e"; | 85 String msg = "Unexpected error $e"; |
| 87 var trace = getAttachedStackTrace(e); | |
| 88 if (trace != null) msg += "\nStackTrace: $trace"; | 86 if (trace != null) msg += "\nStackTrace: $trace"; |
| 89 Expect.fail(msg); | 87 Expect.fail(msg); |
| 90 }); | 88 }); |
| 91 | 89 |
| 92 int count = 0; | 90 int count = 0; |
| 93 makeRequest() { | 91 makeRequest() { |
| 94 Socket.connect("127.0.0.1", server.port).then((socket) { | 92 Socket.connect("127.0.0.1", server.port).then((socket) { |
| 95 socket.write("GET / HTTP/1.0\r\n"); | 93 socket.write("GET / HTTP/1.0\r\n"); |
| 96 socket.write("Connection: Keep-Alive\r\n\r\n"); | 94 socket.write("Connection: Keep-Alive\r\n\r\n"); |
| 97 | 95 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 127 server.listen( | 125 server.listen( |
| 128 (HttpRequest request) { | 126 (HttpRequest request) { |
| 129 Expect.isNull(request.headers.value('content-length')); | 127 Expect.isNull(request.headers.value('content-length')); |
| 130 Expect.equals(-1, request.contentLength); | 128 Expect.equals(-1, request.contentLength); |
| 131 var response = request.response; | 129 var response = request.response; |
| 132 response.contentLength = 1; | 130 response.contentLength = 1; |
| 133 Expect.equals("1.0", request.protocolVersion); | 131 Expect.equals("1.0", request.protocolVersion); |
| 134 response.write("Z"); | 132 response.write("Z"); |
| 135 response.close(); | 133 response.close(); |
| 136 }, | 134 }, |
| 137 onError: (e) { | 135 onError: (e, trace) { |
| 138 String msg = "Unexpected error $e"; | 136 String msg = "Unexpected error $e"; |
| 139 var trace = getAttachedStackTrace(e); | |
| 140 if (trace != null) msg += "\nStackTrace: $trace"; | 137 if (trace != null) msg += "\nStackTrace: $trace"; |
| 141 Expect.fail(msg); | 138 Expect.fail(msg); |
| 142 }); | 139 }); |
| 143 | 140 |
| 144 Socket.connect("127.0.0.1", server.port).then((socket) { | 141 Socket.connect("127.0.0.1", server.port).then((socket) { |
| 145 void sendRequest() { | 142 void sendRequest() { |
| 146 socket.write("GET / HTTP/1.0\r\n"); | 143 socket.write("GET / HTTP/1.0\r\n"); |
| 147 socket.write("Connection: Keep-Alive\r\n\r\n"); | 144 socket.write("Connection: Keep-Alive\r\n\r\n"); |
| 148 } | 145 } |
| 149 | 146 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 HttpServer.bind("127.0.0.1", 0).then((server) { | 179 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 183 server.listen( | 180 server.listen( |
| 184 (HttpRequest request) { | 181 (HttpRequest request) { |
| 185 Expect.isNull(request.headers.value('content-length')); | 182 Expect.isNull(request.headers.value('content-length')); |
| 186 Expect.equals(-1, request.contentLength); | 183 Expect.equals(-1, request.contentLength); |
| 187 var response = request.response; | 184 var response = request.response; |
| 188 Expect.equals("1.0", request.protocolVersion); | 185 Expect.equals("1.0", request.protocolVersion); |
| 189 response.write("Z"); | 186 response.write("Z"); |
| 190 response.close(); | 187 response.close(); |
| 191 }, | 188 }, |
| 192 onError: (e) { | 189 onError: (e, trace) { |
| 193 String msg = "Unexpected error $e"; | 190 String msg = "Unexpected error $e"; |
| 194 var trace = getAttachedStackTrace(e); | |
| 195 if (trace != null) msg += "\nStackTrace: $trace"; | 191 if (trace != null) msg += "\nStackTrace: $trace"; |
| 196 Expect.fail(msg); | 192 Expect.fail(msg); |
| 197 }); | 193 }); |
| 198 | 194 |
| 199 int count = 0; | 195 int count = 0; |
| 200 makeRequest() { | 196 makeRequest() { |
| 201 Socket.connect("127.0.0.1", server.port).then((socket) { | 197 Socket.connect("127.0.0.1", server.port).then((socket) { |
| 202 socket.write("GET / HTTP/1.0\r\n"); | 198 socket.write("GET / HTTP/1.0\r\n"); |
| 203 socket.write("Connection: Keep-Alive\r\n\r\n"); | 199 socket.write("Connection: Keep-Alive\r\n\r\n"); |
| 204 | 200 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 224 }); | 220 }); |
| 225 } | 221 } |
| 226 | 222 |
| 227 | 223 |
| 228 void main() { | 224 void main() { |
| 229 testHttp10NoKeepAlive(); | 225 testHttp10NoKeepAlive(); |
| 230 testHttp10ServerClose(); | 226 testHttp10ServerClose(); |
| 231 testHttp10KeepAlive(); | 227 testHttp10KeepAlive(); |
| 232 testHttp10KeepAliveServerCloses(); | 228 testHttp10KeepAliveServerCloses(); |
| 233 } | 229 } |
| OLD | NEW |