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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 class _HttpIncoming extends Stream<List<int>> { | 7 class _HttpIncoming extends Stream<List<int>> { |
8 final int _transferLength; | 8 final int _transferLength; |
9 final Completer _dataCompleter = new Completer(); | 9 final Completer _dataCompleter = new Completer(); |
10 Stream<List<int>> _stream; | 10 Stream<List<int>> _stream; |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 }); | 1251 }); |
1252 return cr; | 1252 return cr; |
1253 } | 1253 } |
1254 | 1254 |
1255 void _removeCredentials(_Credentials cr) { | 1255 void _removeCredentials(_Credentials cr) { |
1256 int index = _credentials.indexOf(cr); | 1256 int index = _credentials.indexOf(cr); |
1257 if (index != -1) { | 1257 if (index != -1) { |
1258 _credentials.removeAt(index); | 1258 _credentials.removeAt(index); |
1259 } | 1259 } |
1260 } | 1260 } |
| 1261 |
| 1262 static String _findProxyFromEnvironment(Uri url, |
| 1263 Map<String, String> environment) { |
| 1264 checkNoProxy(String option) { |
| 1265 if (option == null) return null; |
| 1266 Iterator<String> names = option.split(",").map((s) => s.trim()).iterator; |
| 1267 while (names.moveNext()) { |
| 1268 if (url.domain.endsWith(names.current)) { |
| 1269 return "DIRECT"; |
| 1270 } |
| 1271 } |
| 1272 return null; |
| 1273 } |
| 1274 |
| 1275 checkProxy(String option) { |
| 1276 if (option == null) return null; |
| 1277 int pos = option.indexOf("://"); |
| 1278 if (pos >= 0) { |
| 1279 option = option.substring(pos + 3); |
| 1280 } |
| 1281 if (option.indexOf(":") == -1) option = "$option:1080"; |
| 1282 return "PROXY $option"; |
| 1283 } |
| 1284 |
| 1285 // Default to using the process current environment. |
| 1286 if (environment == null) environment = Platform.environment; |
| 1287 |
| 1288 String proxyCfg; |
| 1289 |
| 1290 String noProxy = environment["no_proxy"]; |
| 1291 if (noProxy == null) noProxy = environment["NO_PROXY"]; |
| 1292 if ((proxyCfg = checkNoProxy(noProxy)) != null) { |
| 1293 return proxyCfg; |
| 1294 } |
| 1295 |
| 1296 if (url.scheme == "http") { |
| 1297 String proxy = environment["http_proxy"]; |
| 1298 if (proxy == null) proxy = environment["HTTP_PROXY"]; |
| 1299 if ((proxyCfg = checkProxy(proxy)) != null) { |
| 1300 return proxyCfg; |
| 1301 } |
| 1302 } else if (url.scheme == "https") { |
| 1303 String proxy = environment["https_proxy"]; |
| 1304 if (proxy == null) proxy = environment["HTTPS_PROXY"]; |
| 1305 if ((proxyCfg = checkProxy(proxy)) != null) { |
| 1306 return proxyCfg; |
| 1307 } |
| 1308 } |
| 1309 return "DIRECT"; |
| 1310 } |
1261 } | 1311 } |
1262 | 1312 |
1263 | 1313 |
1264 class _HttpConnection { | 1314 class _HttpConnection { |
1265 static const _ACTIVE = 0; | 1315 static const _ACTIVE = 0; |
1266 static const _IDLE = 1; | 1316 static const _IDLE = 1; |
1267 static const _CLOSING = 2; | 1317 static const _CLOSING = 2; |
1268 static const _DETACHED = 3; | 1318 static const _DETACHED = 3; |
1269 | 1319 |
1270 int _state = _IDLE; | 1320 int _state = _IDLE; |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 | 1770 |
1721 | 1771 |
1722 class _RedirectInfo implements RedirectInfo { | 1772 class _RedirectInfo implements RedirectInfo { |
1723 const _RedirectInfo(int this.statusCode, | 1773 const _RedirectInfo(int this.statusCode, |
1724 String this.method, | 1774 String this.method, |
1725 Uri this.location); | 1775 Uri this.location); |
1726 final int statusCode; | 1776 final int statusCode; |
1727 final String method; | 1777 final String method; |
1728 final Uri location; | 1778 final Uri location; |
1729 } | 1779 } |
OLD | NEW |