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 | 5 |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
8 | 8 |
9 class Handler1 { | 9 class Handler1 { |
10 void onRequest(HttpRequest request, HttpResponse response) { | 10 void onRequest(HttpRequest request, HttpResponse response) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 conn.onResponse = (HttpClientResponse response) { | 94 conn.onResponse = (HttpClientResponse response) { |
95 Expect.equals(HttpStatus.NOT_FOUND, response.statusCode); | 95 Expect.equals(HttpStatus.NOT_FOUND, response.statusCode); |
96 Expect.equals("Nicht Gefunden", response.reasonPhrase); | 96 Expect.equals("Nicht Gefunden", response.reasonPhrase); |
97 | 97 |
98 // Install another default handler. | 98 // Install another default handler. |
99 server.defaultHandler = new French404Handler(); | 99 server.defaultHandler = new French404Handler(); |
100 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); | 100 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); |
101 conn.onResponse = (HttpClientResponse response) { | 101 conn.onResponse = (HttpClientResponse response) { |
102 Expect.equals(HttpStatus.NOT_FOUND, response.statusCode); | 102 Expect.equals(HttpStatus.NOT_FOUND, response.statusCode); |
103 Expect.equals("Non Trouvé", response.reasonPhrase); | 103 Expect.equals("Non Trouvé", response.reasonPhrase); |
104 done(); | 104 response.inputStream.onClosed = done; |
105 }; | 105 }; |
106 conn.onError = error; | 106 conn.onError = error; |
107 }; | 107 }; |
108 conn.onError = error; | 108 conn.onError = error; |
109 }; | 109 }; |
110 conn.onError = error; | 110 conn.onError = error; |
111 } | 111 } |
112 | 112 |
113 void testHandlers() { | 113 void testHandlers() { |
114 Server server = new Server(); | 114 Server server = new Server(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 testRequest("/yyy.dat", HttpStatus.OK, "Handler 3"); | 178 testRequest("/yyy.dat", HttpStatus.OK, "Handler 3"); |
179 testRequest("/abc.dat", HttpStatus.OK, "Handler 4"); | 179 testRequest("/abc.dat", HttpStatus.OK, "Handler 4"); |
180 testRequest("/abcdat", HttpStatus.NOT_FOUND, ""); | 180 testRequest("/abcdat", HttpStatus.NOT_FOUND, ""); |
181 testRequest("/xxx.dat", HttpStatus.OK, "Handler 2"); | 181 testRequest("/xxx.dat", HttpStatus.OK, "Handler 2"); |
182 } | 182 } |
183 | 183 |
184 main() { | 184 main() { |
185 testDefaultHandler(); | 185 testDefaultHandler(); |
186 testHandlers(); | 186 testHandlers(); |
187 } | 187 } |
OLD | NEW |