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

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

Issue 9863031: Don't propagate http client error, when no response object is available. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
« no previous file with comments | « runtime/bin/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:uri"); 6 #import("dart:uri");
7 #import("dart:isolate");
7 8
8 void testGoogle() { 9 void testGoogle() {
9 HttpClient client = new HttpClient(); 10 HttpClient client = new HttpClient();
10 var conn = client.get('www.google.com', 80, '/'); 11 var conn = client.get('www.google.com', 80, '/');
11 12
12 conn.onRequest = (HttpClientRequest request) { 13 conn.onRequest = (HttpClientRequest request) {
13 request.keepAlive = false; 14 request.keepAlive = false;
14 request.outputStream.close(); 15 request.outputStream.close();
15 }; 16 };
16 conn.onResponse = (HttpClientResponse response) { 17 conn.onResponse = (HttpClientResponse response) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 56 }
56 57
57 void testInvalidUrl() { 58 void testInvalidUrl() {
58 HttpClient client = new HttpClient(); 59 HttpClient client = new HttpClient();
59 Expect.throws( 60 Expect.throws(
60 () => client.getUrl(new Uri.fromString('ftp://www.google.com'))); 61 () => client.getUrl(new Uri.fromString('ftp://www.google.com')));
61 Expect.throws( 62 Expect.throws(
62 () => client.getUrl(new Uri.fromString('http://usr:pwd@www.google.com'))); 63 () => client.getUrl(new Uri.fromString('http://usr:pwd@www.google.com')));
63 } 64 }
64 65
66 void testBadHostName() {
67 HttpClient client = new HttpClient();
68 HttpClientConnection connection =
69 client.get("some.bad.host.name.7654321", 0, "/");
70 connection.onRequest = (HttpClientRequest request) {
71 Expect.fail("Should not open a request on bad hostname");
72 };
73 ReceivePort port = new ReceivePort();
74 connection.onError = (Exception error) {
75 port.close(); // We expect onError to be called, due to bad host name.
76 };
77 }
78
65 void main() { 79 void main() {
66 // TODO(sgjesse): Making empty www.google.com requests seems to fail 80 // TODO(sgjesse): Making empty www.google.com requests seems to fail
67 //on buildbot. 81 //on buildbot.
68 //testGoogle(); 82 //testGoogle();
69 //testGoogleUrl(); 83 //testGoogleUrl();
70 testInvalidUrl(); 84 testInvalidUrl();
85 testBadHostName();
71 } 86 }
OLDNEW
« no previous file with comments | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698