| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 SendPort get dispatchSendPort => _dispatchPort.sendPort; | 212 SendPort get dispatchSendPort => _dispatchPort.sendPort; |
| 213 | 213 |
| 214 void dispatch(message) { | 214 void dispatch(message) { |
| 215 IsolatedHttpServerCommand command = message[0]; | 215 IsolatedHttpServerCommand command = message[0]; |
| 216 SendPort replyTo = message[1]; | 216 SendPort replyTo = message[1]; |
| 217 if (command.isStart) { | 217 if (command.isStart) { |
| 218 try { | 218 try { |
| 219 HttpServer.bind("127.0.0.1", 0).then((server) { | 219 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 220 _server = server; | 220 _server = server; |
| 221 _server.listen(_requestReceivedHandler); | 221 _server.listen(_requestReceivedHandler); |
| 222 replyTo.send(new IsolatedHttpServerStatus.started(_server.port), | 222 replyTo.send(new IsolatedHttpServerStatus.started(_server.port)); |
| 223 null); | |
| 224 }); | 223 }); |
| 225 } catch (e) { | 224 } catch (e) { |
| 226 replyTo.send(new IsolatedHttpServerStatus.error(), null); | 225 replyTo.send(new IsolatedHttpServerStatus.error()); |
| 227 } | 226 } |
| 228 } else if (command.isStop) { | 227 } else if (command.isStop) { |
| 229 _server.close(); | 228 _server.close(); |
| 230 _dispatchPort.close(); | 229 _dispatchPort.close(); |
| 231 replyTo.send(new IsolatedHttpServerStatus.stopped(), null); | 230 replyTo.send(new IsolatedHttpServerStatus.stopped()); |
| 232 } else if (command.isChunkedEncoding) { | 231 } else if (command.isChunkedEncoding) { |
| 233 _chunkedEncoding = true; | 232 _chunkedEncoding = true; |
| 234 } | 233 } |
| 235 } | 234 } |
| 236 | 235 |
| 237 void _requestReceivedHandler(HttpRequest request) { | 236 void _requestReceivedHandler(HttpRequest request) { |
| 238 var requestHandler =_requestHandlers[request.uri.path]; | 237 var requestHandler =_requestHandlers[request.uri.path]; |
| 239 if (requestHandler != null) { | 238 if (requestHandler != null) { |
| 240 requestHandler(request); | 239 requestHandler(request); |
| 241 } else { | 240 } else { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 431 |
| 433 void main() { | 432 void main() { |
| 434 testHost().then((_) { | 433 testHost().then((_) { |
| 435 return testExpires().then((_) { | 434 return testExpires().then((_) { |
| 436 return testContentType().then((_) { | 435 return testContentType().then((_) { |
| 437 return testCookies(); | 436 return testCookies(); |
| 438 }); | 437 }); |
| 439 }); | 438 }); |
| 440 }); | 439 }); |
| 441 } | 440 } |
| OLD | NEW |