| OLD | NEW |
| 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 import "dart:isolate"; | 5 import "dart:isolate"; |
| 6 import "dart:io"; | 6 import "dart:io"; |
| 7 | 7 |
| 8 void testNoBody(int totalConnections, bool explicitContentLength) { | 8 void testNoBody(int totalConnections, bool explicitContentLength) { |
| 9 HttpServer server = new HttpServer(); | 9 HttpServer server = new HttpServer(); |
| 10 server.onError = (e) => Expect.fail("Unexpected error $e"); | 10 server.onError = (e) => Expect.fail("Unexpected error $e"); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 Expect.equals(-1, request.contentLength); | 177 Expect.equals(-1, request.contentLength); |
| 178 response.contentLength = 0; | 178 response.contentLength = 0; |
| 179 OutputStream stream = response.outputStream; | 179 OutputStream stream = response.outputStream; |
| 180 Expect.equals("1.0", request.protocolVersion); | 180 Expect.equals("1.0", request.protocolVersion); |
| 181 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); | 181 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); |
| 182 stream.close(); | 182 stream.close(); |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 Socket socket = new Socket("127.0.0.1", server.port); | 185 Socket socket = new Socket("127.0.0.1", server.port); |
| 186 socket.onConnect = () { | 186 socket.onConnect = () { |
| 187 List<int> buffer = new List<int>(1024); | 187 List<int> buffer = new List<int>.fixedLength(1024); |
| 188 socket.outputStream.writeString("GET / HTTP/1.0\r\n\r\n"); | 188 socket.outputStream.writeString("GET / HTTP/1.0\r\n\r\n"); |
| 189 socket.onData = () => socket.readList(buffer, 0, buffer.length); | 189 socket.onData = () => socket.readList(buffer, 0, buffer.length); |
| 190 socket.onClosed = () { | 190 socket.onClosed = () { |
| 191 socket.close(true); | 191 socket.close(true); |
| 192 server.close(); | 192 server.close(); |
| 193 }; | 193 }; |
| 194 }; | 194 }; |
| 195 } | 195 } |
| 196 | 196 |
| 197 void main() { | 197 void main() { |
| 198 testNoBody(5, false); | 198 testNoBody(5, false); |
| 199 testNoBody(5, true); | 199 testNoBody(5, true); |
| 200 testBody(5, false); | 200 testBody(5, false); |
| 201 testBody(5, true); | 201 testBody(5, true); |
| 202 testBodyChunked(5, false); | 202 testBodyChunked(5, false); |
| 203 testBodyChunked(5, true); | 203 testBodyChunked(5, true); |
| 204 testHttp10(); | 204 testHttp10(); |
| 205 } | 205 } |
| OLD | NEW |