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

Side by Side Diff: tests/standalone/src/io/HttpServerSocketTest.dart

Issue 10119005: Add HTTP handler registration to the HTTP server (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 8 months 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
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 7
8 class ExpectedDataOutputStream implements OutputStream { 8 class ExpectedDataOutputStream implements OutputStream {
9 ExpectedDataOutputStream(List<int> this._data, 9 ExpectedDataOutputStream(List<int> this._data,
10 int this._cutoff, 10 int this._cutoff,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 HttpServer server = new HttpServer(); 165 HttpServer server = new HttpServer();
166 server.listenOn(serverSocket); 166 server.listenOn(serverSocket);
167 void testContent(String request, 167 void testContent(String request,
168 String response, 168 String response,
169 [int okayFrom = 0, 169 [int okayFrom = 0,
170 bool expectError = true]) { 170 bool expectError = true]) {
171 // Inner callback to actually run a given setting. 171 // Inner callback to actually run a given setting.
172 void runSettings(int cutoff, 172 void runSettings(int cutoff,
173 bool closeAsError, 173 bool closeAsError,
174 bool expectError) { 174 bool expectError) {
175 server.onRequest = (HttpRequest request, HttpResponse response) { 175 server.defaultRequestHandler =
176 request.inputStream.onData = () { 176 (HttpRequest request, HttpResponse response) {
177 }; 177 request.inputStream.onData = () {
178 request.inputStream.onClosed = () { 178 };
179 response.outputStream.close(); 179 request.inputStream.onClosed = () {
180 }; 180 response.outputStream.close();
181 }; 181 };
182 };
182 183
183 if (expectError) { 184 if (expectError) {
184 ReceivePort port = new ReceivePort(); 185 ReceivePort port = new ReceivePort();
185 server.onError = (Exception error) { 186 server.onError = (Exception error) {
186 port.close(); 187 port.close();
187 }; 188 };
188 } else { 189 } else {
189 server.onError = (Exception error) { 190 server.onError = (Exception error) {
190 Expect.fail("An error was not expected: $error"); 191 Expect.fail("An error was not expected: $error");
191 }; 192 };
(...skipping 12 matching lines...) Expand all
204 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", 205 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n",
205 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" + 206 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" +
206 "\r\n\r\n0\r\n\r\n"); 207 "\r\n\r\n0\r\n\r\n");
207 208
208 server.close(); 209 server.close();
209 } 210 }
210 211
211 void main() { 212 void main() {
212 testSocketClose(); 213 testSocketClose();
213 } 214 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/HttpServerHandlerTest.dart ('k') | tests/standalone/src/io/HttpServerTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698