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

Unified Diff: tests/standalone/io/http_connection_info_test.dart

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: tests/standalone/io/http_connection_info_test.dart
diff --git a/tests/standalone/io/http_connection_info_test.dart b/tests/standalone/io/http_connection_info_test.dart
index 627d0fc911bc00789219ffc213902138c33720d4..54c06287df827852720c622d98885d7bb70c997f 100644
--- a/tests/standalone/io/http_connection_info_test.dart
+++ b/tests/standalone/io/http_connection_info_test.dart
@@ -1,44 +1,46 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "dart:io";
void testHttpConnectionInfo() {
- HttpServer server = new HttpServer();
- server.listen("0.0.0.0", 0);
- int clientPort;
- server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
- Expect.isTrue(request.connectionInfo.remoteHost is String);
- Expect.equals(request.connectionInfo.localPort, server.port);
- Expect.isNotNull(clientPort);
- Expect.equals(request.connectionInfo.remotePort, clientPort);
- request.inputStream.onClosed = () {
- response.outputStream.close();
- };
- };
- server.onError = (Exception e) {
- Expect.fail("Unexpected error: $e");
- };
+ HttpServer.bind("0.0.0.0", 0).then((server) {
+ int clientPort;
+ server.listen((request) {
+ var response = request.response;
+ Expect.isTrue(request.connectionInfo.remoteHost is String);
+ Expect.isTrue(response.connectionInfo.remoteHost is String);
+ Expect.equals(request.connectionInfo.localPort, server.port);
+ Expect.equals(response.connectionInfo.localPort, server.port);
+ Expect.isNotNull(clientPort);
+ Expect.equals(request.connectionInfo.remotePort, clientPort);
+ Expect.equals(response.connectionInfo.remotePort, clientPort);
+ request.listen(
+ (_) { },
+ onDone: () { request.response.close(); });
+ });
- HttpClient client = new HttpClient();
- HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
- conn.onRequest = (HttpClientRequest request) {
- Expect.isTrue(conn.connectionInfo.remoteHost is String);
- Expect.equals(conn.connectionInfo.remotePort, server.port);
- clientPort = conn.connectionInfo.localPort;
- request.outputStream.close();
- };
- conn.onResponse = (HttpClientResponse response) {
- response.inputStream.onClosed = () {
- client.shutdown();
- server.close();
- };
- };
- conn.onError = (Exception e) {
- Expect.fail("Unexpected error: $e");
- };
+ HttpClient client = new HttpClient();
+ client.get("127.0.0.1", server.port, "/")
+ .then((request) {
+ Expect.isTrue(request.connectionInfo.remoteHost is String);
+ Expect.equals(request.connectionInfo.remotePort, server.port);
+ clientPort = request.connectionInfo.localPort;
+ return request.close();
+ })
+ .then((response) {
+ Expect.equals(server.port, response.connectionInfo.remotePort);
+ Expect.equals(clientPort, response.connectionInfo.localPort);
+ response.listen(
+ (_) { },
+ onDone: () {
+ client.close();
+ server.close();
+ });
+ });
+ });
}
void main() {
« no previous file with comments | « tests/standalone/io/http_connection_header_test.dart ('k') | tests/standalone/io/http_content_length_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698