| 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, |
| 11 int this._cutoff, | 11 int this._cutoff, |
| 12 bool this._closeAsError, | 12 bool this._closeAsError, |
| 13 SocketMock this._socket); | 13 SocketMock this._socket); |
| 14 | 14 |
| 15 void set onNoPendingWrites(void callback()) { | 15 void set onNoPendingWrites(void callback()) { |
| 16 _onNoPendingWrites = callback; | 16 _onNoPendingWrites = callback; |
| 17 } | 17 } |
| 18 | 18 |
| 19 void set onError(void callback(e)) { | 19 void set onError(void callback(e)) { |
| 20 _onError = callback; | 20 _onError = callback; |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool write(List data, [bool copyBuffer = true]) { | 23 bool write(List data, [bool copyBuffer = true]) { |
| 24 _onData(data); | 24 _onData(data); |
| 25 return true; | 25 return true; |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool writeFrom(List data, [int offset = 0, int len]) { | 28 bool writeFrom(List data, [int offset = 0, int len]) { |
| 29 if (len === null) len = data.length - offset; | 29 if (len == null) len = data.length - offset; |
| 30 _onData(data.getRange(offset, len)); | 30 _onData(data.getRange(offset, len)); |
| 31 return true; | 31 return true; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void close() { | 34 void close() { |
| 35 _socket.close(true); | 35 _socket.close(true); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void _onData(List<int> data) { | 38 void _onData(List<int> data) { |
| 39 // TODO(ajohnsen): To be removed, since the socket should not be written to | 39 // TODO(ajohnsen): To be removed, since the socket should not be written to |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", | 224 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", |
| 225 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" | 225 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" |
| 226 "\r\n\r\n0\r\n\r\n"); | 226 "\r\n\r\n0\r\n\r\n"); |
| 227 | 227 |
| 228 server.close(); | 228 server.close(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void main() { | 231 void main() { |
| 232 testSocketClose(); | 232 testSocketClose(); |
| 233 } | 233 } |
| OLD | NEW |