OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 return client.getUrl(url) | 180 return client.getUrl(url) |
181 .then((HttpClientRequest request) => request.close()) | 181 .then((HttpClientRequest request) => request.close()) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 main() { | 259 main() { |
260 testUrlUserInfo(); | 260 testUrlUserInfo(); |
261 testBasicNoCredentials(); | 261 testBasicNoCredentials(); |
262 testBasicCredentials(); | 262 testBasicCredentials(); |
263 testBasicAuthenticateCallback(); | 263 testBasicAuthenticateCallback(); |
264 // These teste are not normally run. They can be used for locally | 264 // These teste are not normally run. They can be used for locally |
265 // testing with another web server (e.g. Apache). | 265 // testing with another web server (e.g. Apache). |
266 //testLocalServerBasic(); | 266 //testLocalServerBasic(); |
267 //testLocalServerDigest(); | 267 //testLocalServerDigest(); |
268 } | 268 } |
OLD | NEW |