| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 _requestHandlers = new Map(); | 149 _requestHandlers = new Map(); |
| 150 _requestHandlers["/echo"] = _echoHandler; | 150 _requestHandlers["/echo"] = _echoHandler; |
| 151 _requestHandlers["/0123456789"] = _zeroToTenHandler; | 151 _requestHandlers["/0123456789"] = _zeroToTenHandler; |
| 152 _requestHandlers["/reasonformoving"] = _reasonForMovingHandler; | 152 _requestHandlers["/reasonformoving"] = _reasonForMovingHandler; |
| 153 _requestHandlers["/host"] = _hostHandler; | 153 _requestHandlers["/host"] = _hostHandler; |
| 154 } | 154 } |
| 155 | 155 |
| 156 void dispatch(var message, SendPort replyTo) { | 156 void dispatch(var message, SendPort replyTo) { |
| 157 if (message.isStart) { | 157 if (message.isStart) { |
| 158 try { | 158 try { |
| 159 HttpServer.bind().then((server) { | 159 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 160 _server = server; | 160 _server = server; |
| 161 _server.listen(_requestReceivedHandler); | 161 _server.listen(_requestReceivedHandler); |
| 162 replyTo.send(new TestServerStatus.started(_server.port), null); | 162 replyTo.send(new TestServerStatus.started(_server.port), null); |
| 163 }); | 163 }); |
| 164 } catch (e) { | 164 } catch (e) { |
| 165 replyTo.send(new TestServerStatus.error(), null); | 165 replyTo.send(new TestServerStatus.error(), null); |
| 166 } | 166 } |
| 167 } else if (message.isStop) { | 167 } else if (message.isStop) { |
| 168 _server.close(); | 168 _server.close(); |
| 169 port.close(); | 169 port.close(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 | 312 |
| 313 void main() { | 313 void main() { |
| 314 testStartStop(); | 314 testStartStop(); |
| 315 testGET(); | 315 testGET(); |
| 316 testPOST(true); | 316 testPOST(true); |
| 317 testPOST(false); | 317 testPOST(false); |
| 318 test404(); | 318 test404(); |
| 319 testReasonPhrase(); | 319 testReasonPhrase(); |
| 320 } | 320 } |
| OLD | NEW |