| 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:async'; | 5 import 'dart:async'; |
| 6 import 'dart:crypto'; | 6 import 'dart:crypto'; |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 import 'dart:uri'; | 9 import 'dart:uri'; |
| 10 import 'dart:utf'; | 10 import 'dart:utf'; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 HttpClient client = new HttpClient(); | 161 HttpClient client = new HttpClient(); |
| 162 bool passwordChanged = false; | 162 bool passwordChanged = false; |
| 163 | 163 |
| 164 client.authenticate = (Uri url, String scheme, String realm) { | 164 client.authenticate = (Uri url, String scheme, String realm) { |
| 165 Expect.equals("Basic", scheme); | 165 Expect.equals("Basic", scheme); |
| 166 Expect.equals("realm", realm); | 166 Expect.equals("realm", realm); |
| 167 String username = url.path.substring(1, 6); | 167 String username = url.path.substring(1, 6); |
| 168 String password = url.path.substring(1, 6); | 168 String password = url.path.substring(1, 6); |
| 169 if (passwordChanged) password = "${password}1"; | 169 if (passwordChanged) password = "${password}1"; |
| 170 Completer completer = new Completer(); | 170 Completer completer = new Completer(); |
| 171 new Timer(10, (_) { | 171 new Timer(const Duration(milliseconds: 10), () { |
| 172 client.addCredentials( | 172 client.addCredentials( |
| 173 url, realm, new HttpClientBasicCredentials(username, password)); | 173 url, realm, new HttpClientBasicCredentials(username, password)); |
| 174 completer.complete(true); | 174 completer.complete(true); |
| 175 }); | 175 }); |
| 176 return completer.future; | 176 return completer.future; |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 Future makeRequest(Uri url) { | 179 Future makeRequest(Uri url) { |
| 180 Completer completer = new Completer(); | 180 Completer completer = new Completer(); |
| 181 HttpClientConnection conn = client.getUrl(url); | 181 HttpClientConnection conn = client.getUrl(url); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 main() { | 262 main() { |
| 263 testUrlUserInfo(); | 263 testUrlUserInfo(); |
| 264 testBasicNoCredentials(); | 264 testBasicNoCredentials(); |
| 265 testBasicCredentials(); | 265 testBasicCredentials(); |
| 266 testBasicAuthenticateCallback(); | 266 testBasicAuthenticateCallback(); |
| 267 // These teste are not normally run. They can be used for locally | 267 // These teste are not normally run. They can be used for locally |
| 268 // testing with another web server (e.g. Apache). | 268 // testing with another web server (e.g. Apache). |
| 269 //testLocalServerBasic(); | 269 //testLocalServerBasic(); |
| 270 //testLocalServerDigest(); | 270 //testLocalServerDigest(); |
| 271 } | 271 } |
| OLD | NEW |