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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 var futures = []; | 107 var futures = []; |
108 for (int i = 0; i < 5; i++) { | 108 for (int i = 0; i < 5; i++) { |
109 futures.add( | 109 futures.add( |
110 makeRequest( | 110 makeRequest( |
111 new Uri.fromString("http://127.0.0.1:${server.port}/test$i"))); | 111 new Uri.fromString("http://127.0.0.1:${server.port}/test$i"))); |
112 futures.add( | 112 futures.add( |
113 makeRequest( | 113 makeRequest( |
114 new Uri.fromString("http://127.0.0.1:${server.port}/test$i/xxx"))); | 114 new Uri.fromString("http://127.0.0.1:${server.port}/test$i/xxx"))); |
115 } | 115 } |
116 Futures.wait(futures).then((_) { | 116 Future.wait(futures).then((_) { |
117 server.shutdown(); | 117 server.shutdown(); |
118 client.shutdown(); | 118 client.shutdown(); |
119 }); | 119 }); |
120 } | 120 } |
121 | 121 |
122 void testBasicCredentials() { | 122 void testBasicCredentials() { |
123 Server server = setupServer(); | 123 Server server = setupServer(); |
124 HttpClient client = new HttpClient(); | 124 HttpClient client = new HttpClient(); |
125 | 125 |
126 Future makeRequest(Uri url) { | 126 Future makeRequest(Uri url) { |
(...skipping 16 matching lines...) Expand all Loading... |
143 | 143 |
144 var futures = []; | 144 var futures = []; |
145 for (int i = 0; i < 5; i++) { | 145 for (int i = 0; i < 5; i++) { |
146 futures.add( | 146 futures.add( |
147 makeRequest( | 147 makeRequest( |
148 new Uri.fromString("http://127.0.0.1:${server.port}/test$i"))); | 148 new Uri.fromString("http://127.0.0.1:${server.port}/test$i"))); |
149 futures.add( | 149 futures.add( |
150 makeRequest( | 150 makeRequest( |
151 new Uri.fromString("http://127.0.0.1:${server.port}/test$i/xxx"))); | 151 new Uri.fromString("http://127.0.0.1:${server.port}/test$i/xxx"))); |
152 } | 152 } |
153 Futures.wait(futures).then((_) { | 153 Future.wait(futures).then((_) { |
154 server.shutdown(); | 154 server.shutdown(); |
155 client.shutdown(); | 155 client.shutdown(); |
156 }); | 156 }); |
157 } | 157 } |
158 | 158 |
159 void testBasicAuthenticateCallback() { | 159 void testBasicAuthenticateCallback() { |
160 Server server = setupServer(); | 160 Server server = setupServer(); |
161 HttpClient client = new HttpClient(); | 161 HttpClient client = new HttpClient(); |
162 bool passwordChanged = false; | 162 bool passwordChanged = false; |
163 | 163 |
(...skipping 30 matching lines...) Expand all Loading... |
194 makeRequest( | 194 makeRequest( |
195 new Uri.fromString("http://127.0.0.1:${server.port}/test$i"))); | 195 new Uri.fromString("http://127.0.0.1:${server.port}/test$i"))); |
196 futures.add( | 196 futures.add( |
197 makeRequest( | 197 makeRequest( |
198 new Uri.fromString( | 198 new Uri.fromString( |
199 "http://127.0.0.1:${server.port}/test$i/xxx"))); | 199 "http://127.0.0.1:${server.port}/test$i/xxx"))); |
200 } | 200 } |
201 return futures; | 201 return futures; |
202 } | 202 } |
203 | 203 |
204 Futures.wait(makeRequests()).then((_) { | 204 Future.wait(makeRequests()).then((_) { |
205 makeRequest( | 205 makeRequest( |
206 new Uri.fromString( | 206 new Uri.fromString( |
207 "http://127.0.0.1:${server.port}/passwdchg")).then((_) { | 207 "http://127.0.0.1:${server.port}/passwdchg")).then((_) { |
208 passwordChanged = true; | 208 passwordChanged = true; |
209 Futures.wait(makeRequests()).then((_) { | 209 Future.wait(makeRequests()).then((_) { |
210 server.shutdown(); | 210 server.shutdown(); |
211 client.shutdown(); | 211 client.shutdown(); |
212 }); | 212 }); |
213 }); | 213 }); |
214 }); | 214 }); |
215 } | 215 } |
216 | 216 |
217 void testLocalServerBasic() { | 217 void testLocalServerBasic() { |
218 HttpClient client = new HttpClient(); | 218 HttpClient client = new HttpClient(); |
219 | 219 |
(...skipping 42 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 |