summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2011-03-29 15:55:39 -0700
committerJesse Wilson <jessewilson@google.com>2011-03-29 15:55:39 -0700
commit0c2fd828abec671333b8b88281825fd27a783723 (patch)
tree3333183573be8e1d0da9402a8912b02a1cea69bf /support
parent0843c022f443b5c4a8ea4d298c8b12147989ec92 (diff)
downloadlibcore-0c2fd828abec671333b8b88281825fd27a783723.zip
libcore-0c2fd828abec671333b8b88281825fd27a783723.tar.gz
libcore-0c2fd828abec671333b8b88281825fd27a783723.tar.bz2
Fix MockWebServer to use the same hostname as TestKeyStore.
Change-Id: I31c9f6e9add87a17737eac4f09949540e5da8cb5
Diffstat (limited to 'support')
-rw-r--r--support/src/test/java/tests/http/MockWebServer.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/support/src/test/java/tests/http/MockWebServer.java b/support/src/test/java/tests/http/MockWebServer.java
index 35729ed..0cdd561 100644
--- a/support/src/test/java/tests/http/MockWebServer.java
+++ b/support/src/test/java/tests/http/MockWebServer.java
@@ -81,8 +81,12 @@ public final class MockWebServer {
return port;
}
+ public String getHostName() {
+ return InetAddress.getLoopbackAddress().getHostName();
+ }
+
public Proxy toProxyAddress() {
- return new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", getPort()));
+ return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(getHostName(), getPort()));
}
/**
@@ -91,10 +95,9 @@ public final class MockWebServer {
* @param path the request path, such as "/".
*/
public URL getUrl(String path) throws MalformedURLException, UnknownHostException {
- String host = InetAddress.getLocalHost().getHostName();
return sslSocketFactory != null
- ? new URL("https://" + host + ":" + getPort() + path)
- : new URL("http://" + host + ":" + getPort() + path);
+ ? new URL("https://" + getHostName() + ":" + getPort() + path)
+ : new URL("http://" + getHostName() + ":" + getPort() + path);
}
/**