提交 56e2283f 编写于 作者: C chegar

8006669:...

8006669: sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh fails on mac
Reviewed-by: alanb
上级 85f2f528
...@@ -153,7 +153,7 @@ public class PostThruProxy { ...@@ -153,7 +153,7 @@ public class PostThruProxy {
/* /*
* setup up a proxy * setup up a proxy
*/ */
setupProxy(); SocketAddress pAddr = setupProxy();
/* /*
* we want to avoid URLspoofCheck failures in cases where the cert * we want to avoid URLspoofCheck failures in cases where the cert
...@@ -163,7 +163,8 @@ public class PostThruProxy { ...@@ -163,7 +163,8 @@ public class PostThruProxy {
new NameVerifier()); new NameVerifier());
URL url = new URL("https://" + hostname+ ":" + serverPort); URL url = new URL("https://" + hostname+ ":" + serverPort);
HttpsURLConnection https = (HttpsURLConnection)url.openConnection(); Proxy p = new Proxy(Proxy.Type.HTTP, pAddr);
HttpsURLConnection https = (HttpsURLConnection)url.openConnection(p);
https.setDoOutput(true); https.setDoOutput(true);
https.setRequestMethod("POST"); https.setRequestMethod("POST");
PrintStream ps = null; PrintStream ps = null;
...@@ -200,14 +201,12 @@ public class PostThruProxy { ...@@ -200,14 +201,12 @@ public class PostThruProxy {
} }
} }
static void setupProxy() throws IOException { static SocketAddress setupProxy() throws IOException {
ProxyTunnelServer pserver = new ProxyTunnelServer(); ProxyTunnelServer pserver = new ProxyTunnelServer();
// disable proxy authentication // disable proxy authentication
pserver.needUserAuth(false); pserver.needUserAuth(false);
pserver.start(); pserver.start();
System.setProperty("https.proxyHost", "localhost"); return new InetSocketAddress("localhost", pserver.getPort());
System.setProperty("https.proxyPort", String.valueOf(
pserver.getPort()));
} }
} }
...@@ -152,7 +152,7 @@ public class PostThruProxyWithAuth { ...@@ -152,7 +152,7 @@ public class PostThruProxyWithAuth {
/* /*
* setup up a proxy * setup up a proxy
*/ */
setupProxy(); SocketAddress pAddr = setupProxy();
/* /*
* we want to avoid URLspoofCheck failures in cases where the cert * we want to avoid URLspoofCheck failures in cases where the cert
...@@ -162,7 +162,8 @@ public class PostThruProxyWithAuth { ...@@ -162,7 +162,8 @@ public class PostThruProxyWithAuth {
new NameVerifier()); new NameVerifier());
URL url = new URL("https://" + hostname + ":" + serverPort); URL url = new URL("https://" + hostname + ":" + serverPort);
HttpsURLConnection https = (HttpsURLConnection)url.openConnection(); Proxy p = new Proxy(Proxy.Type.HTTP, pAddr);
HttpsURLConnection https = (HttpsURLConnection)url.openConnection(p);
https.setDoOutput(true); https.setDoOutput(true);
https.setRequestMethod("POST"); https.setRequestMethod("POST");
PrintStream ps = null; PrintStream ps = null;
...@@ -195,7 +196,7 @@ public class PostThruProxyWithAuth { ...@@ -195,7 +196,7 @@ public class PostThruProxyWithAuth {
} }
} }
static void setupProxy() throws IOException { static SocketAddress setupProxy() throws IOException {
ProxyTunnelServer pserver = new ProxyTunnelServer(); ProxyTunnelServer pserver = new ProxyTunnelServer();
/* /*
...@@ -209,9 +210,8 @@ public class PostThruProxyWithAuth { ...@@ -209,9 +210,8 @@ public class PostThruProxyWithAuth {
pserver.setUserAuth("Test", "test123"); pserver.setUserAuth("Test", "test123");
pserver.start(); pserver.start();
System.setProperty("https.proxyHost", "localhost");
System.setProperty("https.proxyPort", String.valueOf( return new InetSocketAddress("localhost", pserver.getPort());
pserver.getPort()));
} }
public static class TestAuthenticator extends Authenticator { public static class TestAuthenticator extends Authenticator {
...@@ -220,6 +220,4 @@ public class PostThruProxyWithAuth { ...@@ -220,6 +220,4 @@ public class PostThruProxyWithAuth {
"test123".toCharArray()); "test123".toCharArray());
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册