Index: tests/standalone/src/io/HttpClientTest.dart |
diff --git a/tests/standalone/src/io/HttpClientTest.dart b/tests/standalone/src/io/HttpClientTest.dart |
index 897e921256ff9f1f69146ce1b4262d2445b09a29..3598b54c899c7a10843835a3a1d46ad78758d02f 100644 |
--- a/tests/standalone/src/io/HttpClientTest.dart |
+++ b/tests/standalone/src/io/HttpClientTest.dart |
@@ -3,6 +3,7 @@ |
// BSD-style license that can be found in the LICENSE file. |
#import("dart:io"); |
+#import("dart:uri"); |
void testGoogle() { |
HttpClient client = new HttpClient(); |
@@ -21,8 +22,48 @@ void testGoogle() { |
client.shutdown(); |
}; |
}; |
+ conn.onError = (error) => Expect.fail("Unexpected IO error"); |
+} |
+ |
+void testGoogleUrl() { |
+ HttpClient client = new HttpClient(); |
+ |
+ void testUrl(String url) { |
+ var conn = client.getUrl(new Uri.fromString(url)); |
+ |
+ conn.onRequest = (HttpClientRequest request) { |
+ request.keepAlive = false; |
+ request.outputStream.close(); |
+ }; |
+ conn.onResponse = (HttpClientResponse response) { |
+ Expect.isTrue(response.statusCode < 500); |
+ response.inputStream.onData = () { |
+ response.inputStream.read(); |
+ }; |
+ response.inputStream.onClosed = () { |
+ client.shutdown(); |
+ }; |
+ }; |
+ conn.onError = (error) => Expect.fail("Unexpected IO error"); |
+ } |
+ |
+ testUrl('http://www.google.com'); |
+ testUrl('http://www.google.com/abc'); |
+ testUrl('http://www.google.com/?abc'); |
+ testUrl('http://www.google.com/abc?abc'); |
+ testUrl('http://www.google.com/abc?abc#abc'); |
+} |
+ |
+void testInvalidUrl() { |
+ HttpClient client = new HttpClient(); |
+ Expect.throws( |
+ () => client.getUrl(new Uri.fromString('ftp://www.google.com'))); |
+ Expect.throws( |
+ () => client.getUrl(new Uri.fromString('http://usr:pwd@www.google.com'))); |
} |
void main() { |
testGoogle(); |
+ testGoogleUrl(); |
+ testInvalidUrl(); |
} |