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: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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 Function _onClosedInternal; | 120 Function _onClosedInternal; |
121 List<int> _data; | 121 List<int> _data; |
122 ExpectedDataOutputStream _outputStream; | 122 ExpectedDataOutputStream _outputStream; |
123 } | 123 } |
124 | 124 |
125 class ServerSocketMock implements ServerSocket { | 125 class ServerSocketMock implements ServerSocket { |
126 ServerSocketMock(String addr, int this._port, int backlog) : | 126 ServerSocketMock(String addr, int this._port, int backlog) : |
127 _sockets = new Set<Socket>(); | 127 _sockets = new Set<Socket>(); |
128 | 128 |
129 void spawnSocket(var data, String response, int cutOff, bool closeAsError) { | 129 void spawnSocket(var data, String response, int cutOff, bool closeAsError) { |
130 if (data is String) data = data.charCodes(); | 130 if (data is String) data = data.charCodes; |
131 SocketMock socket = new SocketMock(data, | 131 SocketMock socket = new SocketMock(data, |
132 response.charCodes(), | 132 response.charCodes, |
133 cutOff, | 133 cutOff, |
134 closeAsError); | 134 closeAsError); |
135 _sockets.add(socket); | 135 _sockets.add(socket); |
136 ReceivePort port = new ReceivePort(); | 136 ReceivePort port = new ReceivePort(); |
137 socket._onClosedInternal = () { | 137 socket._onClosedInternal = () { |
138 // The server should always close the connection. | 138 // The server should always close the connection. |
139 _sockets.remove(socket); | 139 _sockets.remove(socket); |
140 port.close(); | 140 port.close(); |
141 }; | 141 }; |
142 // Tell HttpServer that a connection have come to life. | 142 // Tell HttpServer that a connection have come to life. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", | 212 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", |
213 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" | 213 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" |
214 "\r\n\r\n0\r\n\r\n"); | 214 "\r\n\r\n0\r\n\r\n"); |
215 | 215 |
216 server.close(); | 216 server.close(); |
217 } | 217 } |
218 | 218 |
219 void main() { | 219 void main() { |
220 testSocketClose(); | 220 testSocketClose(); |
221 } | 221 } |
OLD | NEW |