| OLD | NEW |
| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 SendPort get dispatchSendPort => _dispatchPort.sendPort; | 163 SendPort get dispatchSendPort => _dispatchPort.sendPort; |
| 164 | 164 |
| 165 void dispatch(var message) { | 165 void dispatch(var message) { |
| 166 TestServerCommand command = message[0]; | 166 TestServerCommand command = message[0]; |
| 167 SendPort replyTo = message[1]; | 167 SendPort replyTo = message[1]; |
| 168 if (command.isStart) { | 168 if (command.isStart) { |
| 169 try { | 169 try { |
| 170 HttpServer.bind("127.0.0.1", 0).then((server) { | 170 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 171 _server = server; | 171 _server = server; |
| 172 _server.listen(_requestReceivedHandler); | 172 _server.listen(_requestReceivedHandler); |
| 173 replyTo.send(new TestServerStatus.started(_server.port), null); | 173 replyTo.send(new TestServerStatus.started(_server.port)); |
| 174 }); | 174 }); |
| 175 } catch (e) { | 175 } catch (e) { |
| 176 replyTo.send(new TestServerStatus.error(), null); | 176 replyTo.send(new TestServerStatus.error()); |
| 177 } | 177 } |
| 178 } else if (command.isStop) { | 178 } else if (command.isStop) { |
| 179 _server.close(); | 179 _server.close(); |
| 180 _dispatchPort.close(); | 180 _dispatchPort.close(); |
| 181 replyTo.send(new TestServerStatus.stopped(), null); | 181 replyTo.send(new TestServerStatus.stopped()); |
| 182 } else if (command.isChunkedEncoding) { | 182 } else if (command.isChunkedEncoding) { |
| 183 _chunkedEncoding = true; | 183 _chunkedEncoding = true; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 void _requestReceivedHandler(HttpRequest request) { | 187 void _requestReceivedHandler(HttpRequest request) { |
| 188 var requestHandler =_requestHandlers[request.uri.path]; | 188 var requestHandler =_requestHandlers[request.uri.path]; |
| 189 if (requestHandler != null) { | 189 if (requestHandler != null) { |
| 190 requestHandler(request); | 190 requestHandler(request); |
| 191 } else { | 191 } else { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 | 321 |
| 322 void main() { | 322 void main() { |
| 323 testStartStop(); | 323 testStartStop(); |
| 324 testGET(); | 324 testGET(); |
| 325 testPOST(true); | 325 testPOST(true); |
| 326 testPOST(false); | 326 testPOST(false); |
| 327 test404(); | 327 test404(); |
| 328 testReasonPhrase(); | 328 testReasonPhrase(); |
| 329 } | 329 } |
| OLD | NEW |