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 "package:crypto/crypto.dart"; | 5 import "package:crypto/crypto.dart"; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import "package:path/path.dart"; | 7 import "package:path/path.dart"; |
8 import "dart:async"; | 8 import "dart:async"; |
9 import "dart:io"; | 9 import "dart:io"; |
10 import 'dart:convert'; | 10 import 'dart:convert'; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return; | 166 return; |
167 } else { | 167 } else { |
168 Expect.equals( | 168 Expect.equals( |
169 1, request.headers[HttpHeaders.PROXY_AUTHORIZATION].length); | 169 1, request.headers[HttpHeaders.PROXY_AUTHORIZATION].length); |
170 String authorization = | 170 String authorization = |
171 request.headers[HttpHeaders.PROXY_AUTHORIZATION][0]; | 171 request.headers[HttpHeaders.PROXY_AUTHORIZATION][0]; |
172 if (authScheme == "Basic") { | 172 if (authScheme == "Basic") { |
173 List<String> tokens = authorization.split(" "); | 173 List<String> tokens = authorization.split(" "); |
174 Expect.equals("Basic", tokens[0]); | 174 Expect.equals("Basic", tokens[0]); |
175 String auth = | 175 String auth = |
176 CryptoUtils.bytesToBase64(UTF8.encode("$username:$password")); | 176 BASE64.encode(UTF8.encode("$username:$password")); |
177 if (auth != tokens[1]) { | 177 if (auth != tokens[1]) { |
178 basicAuthenticationRequired(request); | 178 basicAuthenticationRequired(request); |
179 return; | 179 return; |
180 } | 180 } |
181 } else { | 181 } else { |
182 HeaderValue header = | 182 HeaderValue header = |
183 HeaderValue.parse( | 183 HeaderValue.parse( |
184 authorization, parameterSeparator: ","); | 184 authorization, parameterSeparator: ","); |
185 Expect.equals("Digest", header.value); | 185 Expect.equals("Digest", header.value); |
186 var uri = header.parameters["uri"]; | 186 var uri = header.parameters["uri"]; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 }); | 469 }); |
470 }); | 470 }); |
471 } | 471 } |
472 | 472 |
473 main() { | 473 main() { |
474 testInvalidProxy(); | 474 testInvalidProxy(); |
475 testDirectProxy(); | 475 testDirectProxy(); |
476 testProxy(); | 476 testProxy(); |
477 testProxyChain(); | 477 testProxyChain(); |
478 } | 478 } |
OLD | NEW |