Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: tests/standalone/io/http_server_socket_test.dart

Issue 11359101: Use Socket.read instead of Socket.readList in HTTP (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 Expect.isFalse(_closed); 77 Expect.isFalse(_closed);
78 _closed = true; 78 _closed = true;
79 _onClosedInternal(); 79 _onClosedInternal();
80 if (asError) { 80 if (asError) {
81 _onError(new Exception("Socket closed unexpected")); 81 _onError(new Exception("Socket closed unexpected"));
82 } else { 82 } else {
83 _onClosed(); 83 _onClosed();
84 } 84 }
85 } 85 }
86 86
87 List<int> read([int len]) {
88 var result;
89 if (len == null) {
90 result = _data;
91 _data = [];
92 } else {
93 result = new Uint8List(len);
94 readList(result, 0, len);
95 }
96 return result;
97 }
98
87 int readList(List<int> buffer, int offset, int count) { 99 int readList(List<int> buffer, int offset, int count) {
88 int max = min(count, _data.length); 100 int max = min(count, _data.length);
89 buffer.setRange(offset, max, _data); 101 buffer.setRange(offset, max, _data);
90 _data = _data.getRange(max, _data.length - max); 102 _data = _data.getRange(max, _data.length - max);
91 return max; 103 return max;
92 } 104 }
93 105
94 void close([bool halfClose = false]) { 106 void close([bool halfClose = false]) {
95 if (!halfClose && !_closed) _closeInternal(); 107 if (!halfClose && !_closed) _closeInternal();
96 } 108 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 "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",
213 "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"
214 "\r\n\r\n0\r\n\r\n"); 226 "\r\n\r\n0\r\n\r\n");
215 227
216 server.close(); 228 server.close();
217 } 229 }
218 230
219 void main() { 231 void main() {
220 testSocketClose(); 232 testSocketClose();
221 } 233 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698