Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: sdk/lib/io/http_impl.dart

Issue 80673002: Better handling of IPv6 with HTTP proxy (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/http_proxy_configuration_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 98ee9b95b85c007d7a65864b967d1ab0d553d56a..9a07d55a1c1458345a72ec13b597575ad60630d9 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -1823,7 +1823,12 @@ class _HttpClient implements HttpClient {
if (option == null) return null;
Iterator<String> names = option.split(",").map((s) => s.trim()).iterator;
while (names.moveNext()) {
- if (url.host.endsWith(names.current)) {
+ var name = names.current;
+ if ((name.startsWith("[") &&
+ name.endsWith("]") &&
+ "[${url.host}]" == name) ||
+ (name.isNotEmpty &&
+ url.host.endsWith(name))) {
return "DIRECT";
}
}
@@ -1832,6 +1837,8 @@ class _HttpClient implements HttpClient {
checkProxy(String option) {
if (option == null) return null;
+ option = option.trim();
+ if (option.isEmpty) return null;
int pos = option.indexOf("://");
if (pos >= 0) {
option = option.substring(pos + 3);
@@ -1840,7 +1847,13 @@ class _HttpClient implements HttpClient {
if (pos >= 0) {
option = option.substring(0, pos);
}
- if (option.indexOf(":") == -1) option = "$option:1080";
+ // Add default port if no port configured.
+ if (option.indexOf("[") == 0) {
+ var pos = option.lastIndexOf(":");
+ if (option.indexOf("]") > pos) option = "$option:1080";
+ } else {
+ if (option.indexOf(":") == -1) option = "$option:1080";
+ }
return "PROXY $option";
}
@@ -2181,12 +2194,15 @@ class _ProxyConfiguration {
password = userinfo.substring(colon + 1).trim();
}
// Look for proxy host and port.
- int colon = proxy.indexOf(":");
+ int colon = proxy.lastIndexOf(":");
if (colon == -1 || colon == 0 || colon == proxy.length - 1) {
throw new HttpException(
"Invalid proxy configuration $configuration");
}
String host = proxy.substring(0, colon).trim();
+ if (host.startsWith("[") && host.endsWith("]")) {
+ host = host.substring(1, host.length - 2);
+ }
String portString = proxy.substring(colon + 1).trim();
int port;
try {
« no previous file with comments | « no previous file | tests/standalone/io/http_proxy_configuration_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698