| 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 import "dart:io"; | 5 import "dart:io"; |
| 6 import "dart:isolate"; | 6 import "dart:isolate"; |
| 7 import "dart:math"; | 7 import "dart:math"; |
| 8 | 8 |
| 9 class ExpectedDataOutputStream implements OutputStream { | 9 class ExpectedDataOutputStream implements OutputStream { |
| 10 ExpectedDataOutputStream(List<int> this._data, | 10 ExpectedDataOutputStream(List<int> this._data, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 Function _onClosedInternal; | 136 Function _onClosedInternal; |
| 137 List<int> _data; | 137 List<int> _data; |
| 138 ExpectedDataOutputStream _outputStream; | 138 ExpectedDataOutputStream _outputStream; |
| 139 } | 139 } |
| 140 | 140 |
| 141 class ServerSocketMock implements ServerSocket { | 141 class ServerSocketMock implements ServerSocket { |
| 142 ServerSocketMock(String addr, int this._port, int backlog) : | 142 ServerSocketMock(String addr, int this._port, int backlog) : |
| 143 _sockets = new Set<Socket>(); | 143 _sockets = new Set<Socket>(); |
| 144 | 144 |
| 145 void spawnSocket(var data, String response, int cutOff, bool closeAsError) { | 145 void spawnSocket(var data, String response, int cutOff, bool closeAsError) { |
| 146 if (data is String) data = data.charCodes; | 146 if (data is String) data = data.codeUnits; |
| 147 SocketMock socket = new SocketMock(data, | 147 SocketMock socket = new SocketMock(data, |
| 148 response.charCodes, | 148 response.codeUnits, |
| 149 cutOff, | 149 cutOff, |
| 150 closeAsError); | 150 closeAsError); |
| 151 _sockets.add(socket); | 151 _sockets.add(socket); |
| 152 ReceivePort port = new ReceivePort(); | 152 ReceivePort port = new ReceivePort(); |
| 153 socket._onClosedInternal = () { | 153 socket._onClosedInternal = () { |
| 154 // The server should always close the connection. | 154 // The server should always close the connection. |
| 155 _sockets.remove(socket); | 155 _sockets.remove(socket); |
| 156 port.close(); | 156 port.close(); |
| 157 }; | 157 }; |
| 158 // Tell HttpServer that a connection have come to life. | 158 // Tell HttpServer that a connection have come to life. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", | 228 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", |
| 229 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" | 229 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" |
| 230 "\r\n\r\n0\r\n\r\n"); | 230 "\r\n\r\n0\r\n\r\n"); |
| 231 | 231 |
| 232 server.close(); | 232 server.close(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void main() { | 235 void main() { |
| 236 testSocketClose(); | 236 testSocketClose(); |
| 237 } | 237 } |
| OLD | NEW |