| 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 #import("dart:io"); | 5 #import("dart:io"); |
| 6 #import("dart:uri"); | 6 #import("dart:uri"); |
| 7 #import("dart:isolate"); | 7 #import("dart:isolate"); |
| 8 | 8 |
| 9 void testGoogle() { | 9 void testGoogle() { |
| 10 HttpClient client = new HttpClient(); | 10 HttpClient client = new HttpClient(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 testUrl('http://www.google.com/abc'); | 50 testUrl('http://www.google.com/abc'); |
| 51 testUrl('http://www.google.com/?abc'); | 51 testUrl('http://www.google.com/?abc'); |
| 52 testUrl('http://www.google.com/abc?abc'); | 52 testUrl('http://www.google.com/abc?abc'); |
| 53 testUrl('http://www.google.com/abc?abc#abc'); | 53 testUrl('http://www.google.com/abc?abc#abc'); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void testInvalidUrl() { | 56 void testInvalidUrl() { |
| 57 HttpClient client = new HttpClient(); | 57 HttpClient client = new HttpClient(); |
| 58 Expect.throws( | 58 Expect.throws( |
| 59 () => client.getUrl(new Uri.fromString('ftp://www.google.com'))); | 59 () => client.getUrl(new Uri.fromString('ftp://www.google.com'))); |
| 60 Expect.throws( | |
| 61 () => client.getUrl(new Uri.fromString('http://usr:pwd@www.google.com'))); | |
| 62 } | 60 } |
| 63 | 61 |
| 64 void testBadHostName() { | 62 void testBadHostName() { |
| 65 HttpClient client = new HttpClient(); | 63 HttpClient client = new HttpClient(); |
| 66 HttpClientConnection connection = | 64 HttpClientConnection connection = |
| 67 client.get("some.bad.host.name.7654321", 0, "/"); | 65 client.get("some.bad.host.name.7654321", 0, "/"); |
| 68 connection.onRequest = (HttpClientRequest request) { | 66 connection.onRequest = (HttpClientRequest request) { |
| 69 Expect.fail("Should not open a request on bad hostname"); | 67 Expect.fail("Should not open a request on bad hostname"); |
| 70 }; | 68 }; |
| 71 ReceivePort port = new ReceivePort(); | 69 ReceivePort port = new ReceivePort(); |
| 72 connection.onError = (Exception error) { | 70 connection.onError = (Exception error) { |
| 73 port.close(); // We expect onError to be called, due to bad host name. | 71 port.close(); // We expect onError to be called, due to bad host name. |
| 74 }; | 72 }; |
| 75 } | 73 } |
| 76 | 74 |
| 77 void main() { | 75 void main() { |
| 78 testGoogle(); | 76 testGoogle(); |
| 79 testGoogleUrl(); | 77 testGoogleUrl(); |
| 80 testInvalidUrl(); | 78 testInvalidUrl(); |
| 81 testBadHostName(); | 79 testBadHostName(); |
| 82 } | 80 } |
| OLD | NEW |