summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-11-04 17:50:15 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-04 17:50:15 -0700
commit7899b0e07650902b69b1983193fb5cbed5789397 (patch)
tree2e5ba2edfb12f13919fb4be225840c885cd2d6d2 /core
parent0ed714a95d1c9c11c3ef8aebd5be4276d1be8740 (diff)
parent6b7af6055f25022361beb2c169d2c1835922dc32 (diff)
downloadframeworks_base-7899b0e07650902b69b1983193fb5cbed5789397.zip
frameworks_base-7899b0e07650902b69b1983193fb5cbed5789397.tar.gz
frameworks_base-7899b0e07650902b69b1983193fb5cbed5789397.tar.bz2
Merge "Use InetAddress.isNumeric."
Diffstat (limited to 'core')
-rw-r--r--core/java/android/net/Proxy.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/core/java/android/net/Proxy.java b/core/java/android/net/Proxy.java
index 23a3ea8..21c485e 100644
--- a/core/java/android/net/Proxy.java
+++ b/core/java/android/net/Proxy.java
@@ -299,15 +299,18 @@ public final class Proxy {
final URI uri = URI.create(url);
final String host = uri.getHost();
if (host != null) {
- // TODO: InetAddress.isLoopbackAddress should be used to check
- // for localhost. However no public factory methods exist which
- // can be used without triggering DNS lookup if host is not localhost.
- if (host.equalsIgnoreCase("localhost") ||
- host.equals("127.0.0.1") ||
- host.equals("[::1]")) {
+ if (host.equalsIgnoreCase("localhost")) {
return true;
}
+ // Check we have a numeric address so we don't cause a DNS lookup in getByName.
+ if (InetAddress.isNumeric(host)) {
+ if (InetAddress.getByName(host).isLoopbackAddress()) {
+ return true;
+ }
+ }
}
+ } catch (UnknownHostException ignored) {
+ // Can't happen for a numeric address (InetAddress.getByName).
} catch (IllegalArgumentException iex) {
// Ignore (URI.create)
}